I have an array of objects in Javascript with two keys with this structure:
"data": [
{
"description": "Unknown",
"type": 0
},
{
"description": "On",
"type": 1
},
{
"description": "Off",
"type": 2
},
...
]
I want to pass it a 'type' numeric value and if it finds it in the array, returns me the description value. For example, if I pass '0', I want it to return 'Unknown'.
This is easily done with a for or forEach loop, but there is an inbuilt function in JS that lets me do it in a single line?