Multiply first element of array to the second element of array like [2*2] ,[4*4] , [4*4], [4*4] and so on...
example
const firstArray = [
[2, 4, 4, 4],
[3, 2, 2, 2],
[1, 5, 9, 1],
[5, 5, 5, 5]
];
const secondArray = [
[2, 4, 4, 4],
[3, 2, 2, 2],
[1, 5, 9, 1],
[5, 5, 5, 5]
];
code
firstArray.map((f, index) => {
f.map((fs, idx) => {
console.log(`${idx} = `, fs * secondArray[index][idx]);
});
});
output
4
16
16
16
9
4
1
25
81
1
25
25
25
25
Top comments (0)