Given
sessionStorage.cart = "[
{"id":121,"name":"Pants","number":1,"specification":""},
{"id":121,"name":"Pants","number":2,"specification":""},
{"id":121,"name":"Pants","number":3,"specification":""}
]"
I'd like to write a function that finds the object with id of 121, name of Pants, number of 2, so that I can update that object's specification. So I would pass the id, the name, the number, and the desired new specification value, and get an output of this:
sessionStorage.cart = "[
{"id":121,"name":"Pants","number":1,"specification":""},
{"id":121,"name":"Pants","number":2,"specification":"new value"},
{"id":121,"name":"Pants","number":3,"specification":""}
]"
Am really struggling on thinking this one through... guidance welcome!
forandif