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

182
Vistas
Evaluating Keys value issues in JS

You are given an object called sumMe containing several key/value pairs and a variable called total whose initial value is 0. Using a for... in loop, iterate through the keys of sumMe; if the value corresponding to a key is a number, add it to total

can someone please explain why I'm getting zero for my result? total should equal 15.

const sumMe = {
  hello: 'there',
  you: 8,
  are: 7,
  almost: '10',
  done: '!'
};

let total = 0;

// iterate by using for...in loop
for (let i in sumMe) {
  // corresponding to a key is a number by using object and value 
  if (typeof Object.values(sumMe) === 'number') {
    // adding the results and total should equal 15.
    total += Object.values(sumMe);
  }
}

// print out 
console.log(total);

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Please make corrections when getting current values in the loop.

const sumMe = {
  hello: 'there',
  you: 8,
  are: 7,
  almost: '10',
  done: '!'
};

let total = 0;

// iterate by using for...in loop
for (let i in sumMe) {
  // corresponding to a key is a number by using object and value 
  if (typeof sumMe[i] === 'number') {
    // adding the results and total should equal 15.
    total += sumMe[i];
  }
}

// print out 
console.log(total);

about 4 years ago · Juan Pablo Isaza Denunciar
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