Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

@zaxxoff
Copy link

@zaxxoff zaxxoff commented Aug 12, 2017

No description provided.

};

const lessThanNinety = (num) => {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be careful about adding extra lines. Spacing and layout is pretty important. Your senior devs at a future job will be super strict about this stuff

// Do not change any of the function names

const getBiggest = (x, y) => {
if (x > y) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I often like to write simple if statements like this: if (x > y) return x;

Spanish: 'Hola!',
Chinese: 'Ni Hao!',
};
return translations[language] || 'Hello!';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a creative approach. You could also do something along the lines of setting a default parameter: (language = 'English') => {.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fine how you had it though

};

const isInteger = (num) => {
const isInteger = num => Math.floor(num) === num;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creative use of floor. You can also use parseInt to do a similar thing. It drops everything after the decimal

};

const returnLast = (arr) => {
const returnLast = arr => arr.pop();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arr.pop() removes the last item from the array. You should do: arr[arr.length - 1]; . This just reads the last item in the array.

};

const wordsToSentence = (words) => {
return `${words.join(' ')}`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could just do return words.join(' ');. It automatically converts it into a string


const contains = (arr, item) => {
return arr.includes(item);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the extra space and you could put this on one line


const addNumbers = (numbers) => {
// numbers is an array of integers.
let out = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work. You could also use Array.reduce


const largestNumber = (numbers) => {
let biggestNumber = numbers[0];
for (let i = 0; i < numbers.length; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good. You could start i = 1 instead of 0 because you've assigned the first value to biggestNumber

const newObject = {
name,
age,
meow: () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, you could also write it as meow: () => 'Meow!'

};

const sumUserPostLikes = (user) => {
let sum = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reduce would work here as well. In the future you'll want to use map, forEach, and reduce whenever possible. This current solution is fine but in the future you'll want to solve these differently :)

const removeDuplicates = (collection, cb) => {
// Write a function called removeDuplicates that removes all duplicate values from the given array.
// Pass the array to the callback function. Do not mutate the original array.
cb(Array.from(new Set(collection)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good use of Set and Array.from

@SunJieMing SunJieMing closed this Aug 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.