If i have an array A = [1, 4, 3, 2] and B = [0, 2, 1, 2] I want to return a new array (A - B) with values [1, 2, 2, 0]. What is the most e
A = [1, 4, 3, 2]
B = [0, 2, 1, 2]
[1, 2, 2, 0]
For Simple and efficient ever.
For
Check here : JsPref - For Vs Map Vs forEach
var a = [1, 4, 3, 2], b = [0, 2, 1, 2], x = []; for(var i = 0;i<=b.length-1;i++) x.push(a[i] - b[i]); console.log(x);