[Solved] How can I access only that key has value true? Object in an array


var letters = [{
    A: true,
    B: false,
    C: false,
    D: false,
    E: false,
    F: false,
    G: false
}]

I came up with this solution. console.log(prop); now returns “$init A”. I would only need “A”. Is it because my array is in a mongodb database?

for (var prop in letters[0]) {
    if (letters[0][prop] === true) {
        console.log(prop);
    }
}

Finally I have made “$init” disappeared using jQuery in my seperated js file by:

$('td:contains("$init")').each(function(){
    $(this).html($(this).html().split("$init").join("<span hidden='true'>$init</span>"));
});

I would like to thank to all of you for your help and effort on this case. Probably it is not the cleanest solution, but does what I need.

solved How can I access only that key has value true? Object in an array