Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

231
Views
Why does output show first letter of first array element instead of whole first array element for arr[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>

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!