Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

229
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda