My task in JavaScript is to change the names of canBook -> quantity
, variationsEN -> variations
, and nested keys valueEN -> value
.
var prod = [{
price: 10,
canBook: 1
}, {
price: 11,
canBook: 2,
variationsEN: [{
valueEN: 1
}, {
valueEN: 2
}]
}]
I have successfully renamed the main keys, but I am struggling with changing the nested ones like valueEN
.
prod.map(p => ({
quantity: p.canBook, variations:p.variationsEN
}))