I'm new in react
I try to search and change value like this.
ny: "76" -> ny: "apple"
ny: "12" -> ny: "banana"
How can I do this?
I tried like this.
const source = [{
nx: "98",
ny: "76",
category: "WSD",
fcstDate: "20210625",
fcstTime: "1500",
fcstValue: "2.9",
},
{
nx: "98",
ny: "12",
category: "S06",
fcstDate: "20210625",
fcstTime: "1200",
fcstValue: "0",
},
]
const newArray = source
.filter(({ny}) => ny === "76")
.forEach((source) => (source.ny = "apple"));
Source
const source = [
{
nx: "98",
ny: "apple",
category: "WSD",
fcstDate: "20210625",
fcstTime: "1500",
fcstValue: "2.9",
},
{
nx: "98",
ny: "banana",
category: "S06",
fcstDate: "20210625",
fcstTime: "1200",
fcstValue: "0",
},
]