Answer the question
In order to leave comments, you need to log in
Javascript how do I multiply an array element by 2?
let newArr =
{
"example": "name",
"word": 12,
"word": "noone",
"word": "2014",
"result": [
{
"name": "Ivan",
"age": "20"
},
{
"name": "OIga",
"age": "30"
}
]
};
let newArr2 = [ ];
Answer the question
In order to leave comments, you need to log in
let newArr =
{
"example": "name",
"word": 12,
"word": "noone",
"word": "2014",
"result": [
{
"name": "Ivan",
"age": "20"
},
{
"name": "OIga",
"age": "30"
}
]
};
let newArr2 = newArr.result.map(el => el.age * 2);
let newArr3 = newArr.result.map(el => {
return {name: el.name, age: el.age * 2};
});
console.log(newArr2);
console.log(newArr3);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question