+ 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
4 Réponses
+ 6
with for loop access each element of array and subtract 10 with each iteration
+ 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!
+ 3
With for loop connect to each index and change its value.
+ 3
const num = numbers.map(n=>n-10);