4 Answers
New AnswerYou can use a simple for loop. Use the document.writeln to print it out. See the below working snippet. array = ["example1", "example2", "example3"]; for (i = 0; i < array.length; i++) document.writeln((i+1) + ": " + array[i]);
There are several ways. Seeing as for loops and for of loops have been mentioned, I'll add forEach to the list. For the outputting itself, you can use console.log, document.write or another couple of methods, depending on your needs. Here's forEach: ["a", "b"].forEach(item => console.log(item))
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message