Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created January 6, 2021 15:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecademydev/857486b75f9df484e774d959f7c499ac to your computer and use it in GitHub Desktop.
Save codecademydev/857486b75f9df484e774d959f7c499ac to your computer and use it in GitHub Desktop.
Codecademy export
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