+ 3
How to subtract from array
This is an array given below I want to subtract 10 from each of the list numbers numbers = [30, 80, 40] And output the numbers In an ARRAY I don’t want it to be ES6
5 Réponses
+ 3
U can transverse the array then subtract
https://code.sololearn.com/cP3tiHxQP63K/?ref=app
+ 2
let newArray = [];
numbers.forEach(x => {
let y = x - 10;
newArray.push(y);
});
console.log(newArray);
declare a new array. then loop through your numbers array with a foreach loop and subtract 10 from each number. then push the result to the newarray.
0
This will help you my friends
0
You can use map() function, then you will have access to each number of the table and then you can subtract each number one by one.
0
Yusuf Hashmi Please delete this duplicate post.