Help with Lesson 3 Section 7 Function Calls

is there someone who can help me to understand why this code won’t run? It’s throwing back Lots of different error messages. That past during the first stepl
Screenshot 2020-11-25 at 22.18.59

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 = (clue, X) => {

let firstAtt = clue(x);
let secondAtt = clue(x);
if (firstAtt === secondAtt) {
  return firstAtt; 
  } else { return `This function returned inconsistent results`;

  }  
};

If we look at the error message it shows a missing s on the function name yet I cannot find that error in your code. It could well be the SCT that is calling the wrong function, can’t say.

For shits and giggles, drop the final s from both the function and the argument and see what happens. Please report back with the result.

Thanks for pointing out that missing S, I tried to do what you said in the message… but on this exercise The massively Worded Function Only Occurs as an Argument? So i couldn’t delete an S from the Function as in this exercise there isn’t one… Unless I go back to a previous exercise, because the previous use of checkThatTwoPlusTwoEqualsFourAMillionTime
is acting as Globlal Function?

const timeFuncRuntime = funcParameter => {
  let t1 = Date.now();
  funcParameter();
  let t2 = Date.now();
  return t2 - t1;
};

// Write your code below

const time2p2 = timeFuncRuntime(checkThatTwoPlusTwoEqualsFourAMillionTime);

const checkConsistentOutput = (clue, X) => {

let firstAtt = clue(x);
let secondAtt = clue(x);
if (firstAtt === secondAtt) {
  return firstAtt; 
  } else { return `This function returned inconsistent results`;

  }  
};
const checkThatTwoPlusTwoEqualsFourAMillionTimes = () => {

is the function;

const time2p2 = timeFuncRuntime(checkThatTwoPlusTwoEqualsFourAMillionTimes);

is the argument in the function call.

Not sure I follow your question. Are still on the same exercise?

1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.