For the following snippet:
<body>
<p id="demo"></p>
<script>
cars = ("BMW", "Volvo", "Saab", "Ford","Ranjith");
text="";
for(i=0;i<cars.length;i++)
{
text+=cars[i] +"<br/>"
}
document.getElementById("demo").innerHTML = text;
</script>
</body>
Got the output as :
R
a
n
j
i
t
h
The expected output was:
BMW
Volvo
Saab
Ford
Ranjith
What do I need change in my code to get the expected output. what is the reason for such output?