Dewinky Dewinky - 6 months ago 22
Javascript Question

How to get the values in this object?

I have been trying to get the values from the below object without any luck. I know there are many answers out there, but I am a visual person and they are not working for my layout.

Also, how can I address the objects to change the values of "ringAlarm"?

var strRingAlarm = {
sq1 :{ringAlarm:"OFF", alarmName:"Chime1"},
sq2 :{ringAlarm:"NO", alarmName:"Chime2"},
sq3 :{ringAlarm:"NO", alarmName:"Chime3"},
sq4 :{ringAlarm:"NO", alarmName:"Chime4"},
sq5 :{ringAlarm:"NO", alarmName:"Chime5"},
sq6 :{ringAlarm:"NO", alarmName:"Chime6"},
sq7 :{ringAlarm:"NO", alarmName:"Chime7"},
sq8 :{ringAlarm:"NO", alarmName:"Chime8"},
sq9 :{ringAlarm:"NO", alarmName:"Chime9"},
sq10:{ringAlarm:"NO", alarmName:"Chime10"},
sq11:{ringAlarm:"NO", alarmName:"Chime11"},
sq12:{ringAlarm:"NO", alarmName:"Chime11"}
Object.getOwnPropertyNames(strRingAlarm).forEach(function(val, idx, array) {
console.log(val + ' -> ' + val.ringAlarm);


You can get the ringAlarmProperty like this

 for(var prop in strRingAlarm){