-
-
Save codecademydev/857486b75f9df484e774d959f7c499ac to your computer and use it in GitHub Desktop.
Codecademy export
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 checkThatTwoPlusTwoEqualsFourAMillionTimes = () => { | |
for(let i = 1; i <= 1000000; i++) { | |
if ( (2 + 2) != 4) { | |
console.log('Something has gone very wrong :( '); | |
} | |
} | |
}; | |
const addTwo = num => num + 2; | |
const timeFuncRuntime = funcParameter => { | |
let t1 = Date.now(); | |
funcParameter(); | |
let t2 = Date.now(); | |
return t2 - t1; | |
}; | |
// Write your code below | |
const time2p2 = timeFuncRuntime(checkThatTwoPlusTwoEqualsFourAMillionTimes); | |
const checkConsistentOutput = (func, val) => { | |
let t1 = func(val); | |
let t2 = func(val); | |
t1 === t2 ? t1 : 'This function returned inconsistent results'; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment