2👍
✅
Destructure out tempmin, tempmax. Merge them back in as “Minimum…”
let forecasts = {
tempmin: 5,
tempmax: 10,
blahblah: "x"
}
this.foreCasts = (({
tempmin,
tempmax,
...rest
}) => Object.assign(rest, {
"Minimum Temperature": tempmin,
"Maximum Temperature": tempmax
}))(forecasts);
console.log(this.foreCasts);
I prefer Object.assign, but you can also use spread syntax { ...rest, "Maximum Temperature": tempmin, "Maximum Temperature": tempmax }
Source:stackexchange.com