Why my code is not count
?
var a = {
count: [{label:'a', value: 'a'}],
next: [{label:'b', value: 'b'}],
previous: [{label:'c', value: 'c'}],
}
function get_item() {
var x = "a"
for (let item in a){
a[item].forEach(obj => {
console.log(obj.value, x )
if(obj.value === x) {
return item
}
})
}
}
console.log(get_item())
the console logs are bellow:
a a
b a
c a
undefined
you see the a a
, but why it do not is the count
rather than undefined
?