JSFiddle - React, Tailwind, and code Playground

by Egor S.

JavaScript

var json = '[{"id":"1","price":"650.44"},{"id":"2","price":"650.44"},{"id":"3","price":"650.44"}]'
var arr = JSON.parse(json);

function getPrice(arr,id){
	var obj = arr.filter(function(item){
  		return item.id == id
  });
  return obj ? obj[0].price : null;
}
var price =  getPrice(arr,3);
console.log(price);