+ 2
Output values in new line in JS
Hello, I am just learning the Javascript course and below is my code where I am trying to input the values for an array from user and print them in a new line. But for some reason in the output the appear in the same line? I might be making some silly mistake. Can anyone help please? Code: var courses = new Array(); size = prompt("Input the number of elements you want in the array:","Values should be in integrer only"); for(i=0;i<=(size-1);i++) { courses[i]=prompt("Enter the name of the course :"); } for(i=0;i<=size;i++) { if(courses[i]!= null){ document.write("\nCourse Name : " + courses[i]); } else break; }
1 Answer
+ 3
Awesome...It worked like a charm....
Thanks...