Created
March 26, 2019 02:03
-
-
Save dougg0k/2c8c4c78edea64b5c3b520684792ffbb to your computer and use it in GitHub Desktop.
This file contains 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
const ascendingOrderFrequency = arr => { | |
const convertObjToArray = obj => Object.keys(obj).map(key => [key, obj[key]]); | |
const frequencyOrderedObj = arr.reduce((acc, curr) => { | |
acc[curr] ? (acc[curr] += 1) : (acc[curr] = 1); | |
return acc; | |
}, {}); | |
return convertObjToArray(frequencyOrderedObj); | |
}; | |
const numbersMultipleOf = () => { | |
const divisible = (number, by) => number % by === 0; | |
let numbers = []; | |
for (let i = 1; i <= 200; i++) { | |
if (divisible(i, 3) && divisible(i, 5)) { | |
numbers[i] = `${i} BlueRed`; | |
} else if (divisible(i, 3)) { | |
numbers[i] = `${i} Blue`; | |
} else if (divisible(i, 5)) { | |
numbers[i] = `${i} Red`; | |
} else { | |
numbers[i] = `${i}`; | |
} | |
} | |
return numbers; | |
}; | |
const isPalindrome = (word) => typeof word === 'string' && word === word.split('').reverse().join(''); | |
console.log(ascendingOrderFrequency([1, 2, 4, 5, 6, 8, 2, 5, 3, 2, 1])); | |
numbersMultipleOf().map(item => console.log(item)); | |
console.log(isPalindrome("civic")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment