Skip to content

Conversation

@bongster91
Copy link

No description provided.

function getCountriesSortedByPopulation(arr) {
let newArr = []
let sorted = arr.sort((a, b) => b.population - a.population)
sorted.forEach(e => newArr.push(e.country))

Choose a reason for hiding this comment

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

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) {

Choose a reason for hiding this comment

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

How can you use a ternary operator here?

let count = 0
let num = n.toString()
for (let i of num) {
count += 1

Choose a reason for hiding this comment

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

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) {

Choose a reason for hiding this comment

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

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?

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.

2 participants