0

I am practicing html javascript. At chapter about array, I use the syntax:

var arr = new Array(5); for (var i=0; i<arr.length; i++) arr[i] = i; for (var i=0; i<arr.length; i++) document.writeln(i + " " + arr[i]); The problem is, the output can not displayed or viewed. What is the problem with my code? Thank you class & sololearn team.

5th Nov 2022, 4:02 AM
Oliver Pasaribu
Oliver Pasaribu - avatar
2 odpowiedzi
+ 2
works fine for me though .... you could try using console.log or document.body.innerHTML+= i + " " + arr[i]
5th Nov 2022, 5:37 AM
Prashanth Kumar
Prashanth Kumar - avatar
0
I see. But what is the different between the three console.log, document.body.innerHTML and document.write? The last comment document.write is even more looks like C# command.
5th Nov 2022, 6:09 AM
Oliver Pasaribu
Oliver Pasaribu - avatar