Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

177
Views
How can I multiply an array elements between another array?

I want to do it with the forEach loop but I can't do it, what I want to do is the following

For example i have the first array:

let numbersA = [4,5,6,7,8];

Then i have the last array:

let numbersB = [2,3,4,5,6];

The expected output:

4 * 2 = 8

4*3 = 12

4 * 4 = 16

4 * 5 = 20

4 * 6 = 24

and now comes the second multiplication of the first array of the second number:

5 * 2 = 10

5 * 3 = 15

5 * 4 = 20

5 * 5 = 25

5 * 6 = 30

How can I get this result, I want to do it with the forEach loop, using arrow functions but I got stuck

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

let numbersA = [4,5,6,7,8];
let numbersB = [2,3,4,5,6];
numbersA.forEach(a => numbersB.forEach(b => console.log(a * b)));

about 4 years ago · Juan Pablo Isaza Report

0

You could use Template Literals to print out the equation:

let numbersA = [4, 5, 6, 7, 8];
let numbersB = [2, 3, 4, 5, 6];
numbersA.forEach(a => {
    numbersB.forEach(b => console.log(`${a} * ${b} = ${a * b}`));
});

about 4 years ago · Juan Pablo Isaza Report

0

You can do it like this using nested forEach:

numbersA.forEach((itemA) => {
   numbersB.forEach((itemB) => {
       console.log(itemA * itemB);
   });
});
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!