Hey all! New to CodeNewbie and need some help. I've been trying to hone my JS skills, and have been having a head of a time figuring out how to loop through or enumerate JavaScript objects.
Can anyone out there show me the way?
Hey all! New to CodeNewbie and need some help. I've been trying to hone my JS skills, and have been having a head of a time figuring out how to loop through or enumerate JavaScript objects.
Can anyone out there show me the way?
For further actions, you may consider blocking this person and/or reporting abuse
Khoa Nguyen -
swiftproxy -
Marcos Andrew -
JesicaW -
Top comments (3)
The Object.keys( candy clicker ) method returns an array of the object's own enumerable property names, and you can loop through these keys using a for loop or the forEach() method.
Using a for...in loop:
`JavaScript
const myObject = {
name: "Alice",
age: 30,
city: "New York"
};
for (let key in myObject) {
console.log(key, myObject[key]);
}
`
This will output (slope):
name Alice
age 30
city New York
Hi Alex!
You can check this link for how to iterate over JavaScript object flaviocopes.com/how-to-iterate-obj...