here is my javascript object
var students = [
{
name: "Pavel Ravel",
track: "CSS, HTML5, jQUery",
achievements: "145",
points: "353"
},
{
name: "Steve Jobs",
track: "MacOS, iOS",
achievements: "3958735",
points: "09854"
},
{
name: "Bill Gates",
track: "Windows",
achievements: "358798",
points: "37593"
},
{
name: "Gabe Newel",
track: "Steam",
achievements: "5302",
points: "3052"
},
{
name: "Steve Wozniak",
track: "Apple 1 and 2",
achievements: "23562",
points: "3525632"
}
];
What I should do for document.write variable students? I have created for in loop but it writes only undefined.
for ( var studentsList in students ) {
document.write(studentsList[students]);
}
The goal is to write to document this
name: "Pavel Ravel", track: "CSS, HTML5, jQUery", achievements: "145", points: "353"
and so on
document.write(JSON.stringify(students));document.write()with plain text (if you use it at all, which generally you should not). It's meant for use with HTML; if you have other forms of text you need to HTML encode them first or you're asking for (possibly-security-compromising) bugs. Consider something likedocument.body.textContent += "your text"instead.