-4

I have a few arrays, for example:

var number = ["1", "2", "3"];
var name = ["car", "airplane", "train"];
var animal  = ["dog", "cat", "hamster"];

I would like to have an output as

1 car dog

2 airplane cat

3 train hamster

any help is appreciated

thank you in advance

user4821
  • 3
  • 1
  • 1
    [Duplicate](https://google.com/search?q=site%3Astackoverflow.com+js+iterate+multiple+arrays) of [forEach loop through two arrays at the same time in javascript](https://stackoverflow.com/q/57903061/4642212). – Sebastian Simon Feb 23 '21 at 09:30
  • Welcome to Stack Overflow! Please visit the [help], take the [tour] to see what and [ask]. ***>>>[Do some research](https://google.com/search?=site%3Astackoverflow.com+js+iterate+multiple+arrays)<<<***, search for related topics on SO; if you get stuck, post a [mcve] of your attempt, noting input and expected output using the `[<>]` snippet editor. – mplungjan Feb 23 '21 at 09:32

1 Answers1

0

Use the following code.

const number = ["1", "2", "3"];
const name = ["car", "airplane", "train"];
const animal = ["dog", "cat", "hamster"];

for (var i=0; i < number.length; i++)
{
  document.write ( number[i] + " " + name[i] + " " + " " + animal[i] + "<br />" )
}
John Doe
  • 1,401
  • 1
  • 3
  • 14