+ 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

13th Jan 2021, 8:03 AM
Yusuf M Hashmi
5 Réponses
+ 3
U can transverse the array then subtract https://code.sololearn.com/cP3tiHxQP63K/?ref=app
13th Jan 2021, 8:05 AM
Anurag Kumar
Anurag Kumar - avatar
+ 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.
14th Jan 2021, 12:30 AM
Steve
0
This will help you my friends
13th Jan 2021, 8:09 AM
Anurag Kumar
Anurag Kumar - avatar
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.
13th Jan 2021, 10:10 AM
Joyce Bissa
Joyce Bissa - avatar
0
Yusuf Hashmi Please delete this duplicate post.
13th Jan 2021, 12:52 PM
Calviղ
Calviղ - avatar