DEV Community

Discussion on: 7 JavaScript Data Structures you must know

Collapse
 
mpagels profile image
Martin Pagels

Hey Neha, I wanted to let you know that I found some mistakes in your example code:

var users=["neha","ayushi","gauri"]; // creating an array
//iterate over an array
for (i=0;i<user.length;i++){

document.write(emp[i] + ", ");

}

in the for loop there is a "s" missing at user.length. This would throw a ReferenceError.

And in the "document.write" the variable "emp" doesn't make sense. I think you meant "users" instead of "emp".

And I think there is, in the "Common JavaScript Array Methods" picture, at the splice() method example, a little mistake: You're splicing the fruits array, but this is strange, because you named the array "arr".

Maybe fix this, so the readers don't have to fight with wrong code.

Cheers.
Martin

Collapse
 
vellebelle profile image
Morten Vestergaard

Also, i is never declared..

Collapse
 
nehasoni__ profile image
Neha Soni

Oh. thanks for pointing it out 🤝