I am trying to write an JS algorithm in which I have two arrays
.
The value of the first one will have different numerical values. The second array will be constant, say for example [5, 3, 6, 8]
.
Now I would like to multiply the values from the first array, by the corresponding index value from the second array, so having for example such a first array: [3, 7, 2, 5]
it would look like this: 5*3, 3*7, 6*2, 8*5.
From the result I would like to create a new array, which in this case is [15, 21, 12, 40]
.
How can I achieve this result?