Solutons Lounge

react native – How to get an Object value in a single line expression in Javascript


So i have this below object and i want to return true or false based on the value.

obj =   
    {
        "closed": 
            {
                "CS1710897175876283": true
            },
        "unpaid": 
            {
                "CS1711279916237480": false, 
                "CS1711497275526501": true
            }
    }

console.log(obj['closed']) // {"CS1710897175876283": true}, this is fine
console.log(obj['closed']['CS1710897175876283']) // got error "TypeError: Cannot convert undefined value to object"

status={obj['unpaid']['CS1711279916237480'] ? "checked" :  "unchecked"} // got an error as well 

How can get return true or false in just one line.



Source link

Exit mobile version