I’m doing something wrong with this code.
Instructions: Use an object.value() method to return an array of checkObj
's values, and assign this array to a constant called objToArray
. Next, use a for loop to iterate through objToArray
and determine if any of the numbers are divisible by 6. If so, reassign the value of divBy6
to true.
Code:
const checkObj = {
oddNum: 1,
evenNum: 2,
foundNum: 5,
randomNum: 18
};
let divBy6 = false;
console.log(Object.values(checkObj))
const objToArray = [Object.values(checkObj)];
for (let i = 0; i < objToArray.length; i++) {
if (objectToArray[i] % 6 === 0) {
divBy6 = true;
}
}
console.log(objToArray)
Result should be:
[1, 2, 5, 18]
true
Result I get:
[1, 2, 5, 18]
Reference Error on line 15: objectToArray is not defined
How do I define an object.value?