Se le proporciona un objeto llamado sumMe que contiene varios pares clave/valor y una variable llamada total cuyo valor inicial es 0. Usando un bucle for... in, itere a través de las claves de sumMe; si el valor correspondiente a una clave es un número, sumarlo al total
¿Alguien puede explicar por qué obtengo cero en mi resultado? el total debe ser igual a 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);Realice las correcciones cuando obtenga los valores actuales en el ciclo.
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);