Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

227
Views
Functions console.log not good

I came across this exercice on the code academy and I don't understand why my code does not work. can someone explain to me and help me? thank you so much!

  1. Here we have a function, addTwo(), that adds 2 to whatever is passed into it. Below that, we’ve created what will be a higher-order function, checkConsistentOutput(). The purpose of the higher-order function will be to check the work of addTwo(). Let’s get started! To begin, inside the body of checkConsistentOutput(), declare two variables: checkA and checkB:
  • checkA stores the sum val plus 2.
  • checkB stores the invocation of the func callback, with val as the argument.
  1. Next, below the variables, write a conditional statement that checks if the value of checkA is equal to the value checkB. If true, return the result of the callback function. If false, return the string 'inconsistent results'.

  2. Finally, using console.log(), log the invocation of checkConsistentOutput() with two arguments: the addTwo() function and any number.

THIS IS MY CODE:

const addTwo = num => {
  return num + 2;
}

const checkConsistentOutput = (func, val) => {
  let checkA = val + 2;
  let checkB = func(val)
  if (checkA === checkB) {
    return func(val);
  } else {
    return 'inconsistent results';
  }
}

console.log(addTwo(5));

I can't pass the number 3 dunno why?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!