How to return a new array with all values except the first, adding 7 to each For example, addSevenToMost([1, 3, 5]) should return [10, 12]
I tried
let arr = [1, 3, 5];
function addSevenToMost(arr) {
let except = 0;
const newArr = arr.filter((value, index) => index !== except);
return newArr;
}
I only managed to get the new array values except the first, now I don't know how to add 7 to each.
CodePudding user response:
let arr = [1, 3, 5];
let result = arr.slice(1).map(e => e 7)
console.log(result)
CodePudding user response:
const arr = [1, 3, 5]
const result = arr.slice(1).map(item => item 7)
console.log(result)