0
How to do Array to array multiplication in Javascript?
How do we multiply an array using another array of equal elements and the answer should be in an array too. Example: [2,3,5] Ă [4,6,8] Answer = [8,18,40] How do we achieve this example using JavaScript?
4 Answers
+ 2
const matmul = (arr1, arr2) =>
arr1.map((x, i) => x * arr2[i]);
https://code.sololearn.com/cmIQzNpmbGD9/?ref=app
+ 1
We can accept the array to be a matrix then we can use matrix multiplication.
But we must remember that in matrices,
A Ă B â B Ă A always
+ 1
Tibor Santa thanks so much đ,
This is exactly what I was looking for đ.
0
Snehil Pandey [OFFLINE]
And how do we apply this matrix multiplication? .
I haven't come across it yet on my JavaScript tutorial.
Can you give a code example in Javascript please.