I have an array and two inputs. I'd like to take the value of the first input and place that in variable. I have that part down. I'd then like to use that variable to find the corresponding array entry and return another object from that array.
The input is var prodNum=$('input#prodNum').val();
The array is:
var products = [
{
"brand": "brand1",
"prodNum": "01-005",
"YN": "Yes",
"Stock": "Order"
},
{
"brand": "brand2",
"prodNum": "02-005",
"YN": "Yes",
"Stock": "Ship"
},
{
"brand": "brand1",
"prodNum": "01-008",
"YN": "No",
"Stock": "Order"
}
]
I'd like to return the "YN"
value to var YNvalue
, given a certain prodNum
For example if prodNum
= 01-008
, YNvalue
would be "No"