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

179
Views
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 answers
Answer question

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 Report
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!