Open
Conversation
| function getCountriesSortedByPopulation(arr) { | ||
| let newArr = [] | ||
| let sorted = arr.sort((a, b) => b.population - a.population) | ||
| sorted.forEach(e => newArr.push(e.country)) |
There was a problem hiding this comment.
Since .map() returns an array, can you write this function so that you don't need newArr?
| function isOdd() { | ||
|
|
||
| function isOdd(n) { | ||
| if (n % 2 === 0) { |
There was a problem hiding this comment.
How can you use a ternary operator here?
| let count = 0 | ||
| let num = n.toString() | ||
| for (let i of num) { | ||
| count += 1 |
There was a problem hiding this comment.
What is a property that strings have which provides us with the number of characters in the string? You can use this property in place of the for loop.
| function sevenBoom(n) { | ||
| let newArr = [] | ||
| for (let i = 1; i <= n; i += 1) { | ||
| if (i % 7 === 0 || i % 10 === 7) { |
There was a problem hiding this comment.
Consider numbers 70-79; will they be 'BOOM' based on this function? How can you find any number that contains a 7 in any digit?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.