im not yet expert in javascript but I wanted to add a new property in an array of objects with different values which is in an array format.
const mainArray = [{name: 'John', age: 30}, {name: 'Jane', age: 25}]
const country = ['Germany', 'Japan']
const res = mainArray.map(x => {
return {
name: x.name,
age: x.age,
country: country
}
})
i tried this but its not working
expected to be like this
result = [{name: 'John', age: 30, country: 'Germany'}, {name: 'Jane', age: 25, country: 'Japan'}]