0

Why does the output for arr is P and not Piyush?

Output Image

name[0] is giving output P. It should give Piyush right?

var a = 10; //Number
var b = "Hello"; //String
var name = ["Piyush", "Abhigyan", "Aman"]; //Array
var person = {
  firstname: "John",
  lastname: "Cena",
  age: 45,
  color: "white"
}; //Object


document.getElementById("num").innerHTML = a;
document.getElementById("str").innerHTML = b;
document.getElementById("arr").innerHTML = name[0];
document.getElementById("obj").innerHTML = person.color;
<h1>Datatypes</h1>
<p id="num"></p>
<p id="str"></p>
<p id="arr"></p>
<p id="obj"></p>
Richard Deeming
  • 28,664
  • 7
  • 72
  • 132

0 Answers0