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

390
Vistas
Check if property exists in object JSChallenger

I am beginner in javascript coding and I struggle to understand why this code is not ok on jschallenger even though VS Code returns the same output as they suggest there....

***Exercise:*** 
Write a function that takes an object (a) and a string (b) as argument
Return true if the object has a property with key 'b'
Return false otherwise.
Tipp: test case 3 is a bit tricky because the value of property 'z' is undefined
But the property itself exists.

My code: 

function myFunction(a, b)
{
   return (Object.keys(a).includes(b))? 'true' : 'false';
}

console.log(myFunction({a:1, b:2, c:3}, 'b')); // => true
console.log(myFunction({x:'a', y:'b', z:'c'}, 'a')); // => false
console.log(myFunction({x:'a', y:'b', z:undefined}, 'z')); // => true

about 4 years ago · Santiago Gelvez
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