Trying to access integer stored under id's/keys in json object. Why doesn't this code work on its own?
var rooms = {
'kitchen': [7, 40, 36, 16],
'livingroom': 31,
'livingroom2': 15,
'livingroom3': 38,
'gallery': 35,
'gallery2': 29,
'gallery3': 12,
'office': [22, 32],
'neekonsbedroom': 18,
'homeworkroom': 33,
'diningroom': 13,
'atrium': 11
}
function switchOne(id) {
console.log(rooms.id)
}
switchOne('office')
console.log()
returns undefined
, but simply console.log(rooms.office)
returns [ 22, 32 ]
Any and all help is greatly appreciated!
Happy coding!