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
let binarySearch = (haystack, needle) => { | |
let allNums = haystack.every( entry => !isNaN(entry) ); | |
let needleIsNum = !isNaN(needle); | |
if( needleIsNum && allNums){ | |
// prepare inputs | |
haystack = haystack.sort( (a, b) => a - b ); | |
// define Algol | |
let bSearchr = (aHaystack) => { |
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
// Generate similar data from https://www.generatedata.com/ | |
const dummyData = { | |
developers: [ | |
{ | |
"id": "870D1B3F-9259-99A7-F18E-18CA40B3B284", | |
"name": "Heather Bullock", | |
"experience": 12, | |
"stack": "iOS" | |
}, |
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 countdownA = (limit) => { | |
for(let i = limit; i >= 1; i--) { | |
console.log('Now @ ' + i); | |
} | |
}; | |
const countdownB = (limit) => { | |
console.log('Now @ ' + limit); | |
if (limit === 1) return 1; | |
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
export const add = (x, y) => x + y; | |
export const minus = (x, y) => x - y; | |
export const divide = (x, y) => x / y; | |
export const multiply = (x, y) => x * y; |
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
[{ | |
name: 'Alpha Ndimurukundo', | |
age: 33, | |
gender: 'Male', | |
country: 'Rwanda', | |
company: 'Andela' | |
}, ...] |
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 computed = data.reduce((sum, {age = 0}, index) => { | |
const value = sum + age; | |
if(index === data.length-1) return value / data.length; | |
return value; | |
}, 0); |
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
{ | |
name: 'Alpha Ndimurukundo', | |
age: 33, | |
gender: 'Male', | |
country: 'Rwanda', | |
company: 'Andela' | |
} |
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 sumAges = compute(sumOf, 'age'); | |
const sumOfAge = sumAges(data); |
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 avgAge = compute(averageOf, 'age'); | |
const avgOfAges = avgAge(data); |
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 compute = (delegate, field) => { | |
return (data) => delegate(data, field); | |
}; |
OlderNewer