How to divide an array of numbers by another array of numbers

时间:2018-12-03 13:10:33

标签: javascript

Hi guys can someone please help me with some code, so i have two arrays a and b i want to divide a by b. Here is my arrays var a = [ "14", "8", "3", "5" ];

Var b = [ "44", "16", "30", "11" ];

So i want my result to be an array. Please can someone help me

1 个答案:

答案 0 :(得分:0)

You can use Array.map for this

var a = [ "14", "8", "3", "5" ];
var b = [ "44", "16", "30", "11" ];

let res = a.map((d, i) => d/b[i])

console.log(res)