+ 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 https://sololearn.com/coach/983/?ref=app

13th Jan 2021, 11:36 AM
Yusuf M Hashmi
4 Answers
+ 6
with for loop access each element of array and subtract 10 with each iteration
13th Jan 2021, 12:00 PM
Samima Hassan
Samima Hassan - avatar
+ 4
You can do like this, var list = [30, 80, 40] for (let i=0 ; i < 3 ; i++){ list[i] = list[i] - 10 } console.log(list) //[20, 70, 30] Now the all elements of the list, will be subtracted by 10!
13th Jan 2021, 1:30 PM
Abhiyantā
Abhiyantā - avatar
+ 3
With for loop connect to each index and change its value.
13th Jan 2021, 11:48 AM
JaScript
JaScript - avatar
+ 3
const num = numbers.map(n=>n-10);
13th Jan 2021, 12:49 PM
CalviŐ˛
CalviŐ˛ - avatar