Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

192
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda