Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
- let time2p2 = timeFuncRuntime(checkThatTwoPlusTwoEqualsFourAMillionTimes);
- function checkConsistentOutput(funcParam, value){
- let value1 = funcParam(value);
- let value2 = funcParam(value);
- if(value1 === value2){
- return funcParam(value);
- }
- else{
- return 'This function returned inconsistent results';
- }
- }
- checkConsistentOutput(addTwo, 3);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement