I'm trying to add 100 items in an array, where each item contains a number (0-99) and a boolean, by achieving the result below using spread operator and the keys()
method.
for(var i = 0; i < 100; i++){
room.push({roomId: i, isAvailable: true});
}
Is it possible to add a boolean along with each item that was generated with keys()
?
var room = [...Array(100).keys()] // to [{ roomId: 0, isAvailable: true }, ...]