So let's say I have an array and an empty object
let array = ["a", "b", "c", "d", "e", "f"]
let obj = {}
I'm trying to loop through the array, and add each element of that array as a key to the object with a value of 0. How do I do that? I've tried:
for (let i = 0; i < array.length; i++){
for (let key in obj) {
key = array[i]
obj[key] = 0
}
}
The output I'd suppose I'd like to get is something like
console.log({obj})
{a: 0, b: 0, c: 0, d: 0, e: 0, f: 0}