Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Kevin Ohlsson
4,547 Pointsstudents.lenght = undefined
Hello
this does not work:
for (let i = 0; i < students.lenght; i++) {
let stuObj = students[i];
let datas = `<h1>${stuObj.name}</h1>`
datas += `<p>${stuObj.track}</p>`
datas += `<p>${stuObj.achievements}</p>`
datas += `<p>${stuObj.points}</p>`
print(datas)
}
function print(arg) {
document.write(`<div> ${arg} </div>`)
}
but this does
for (let i = 0; i < 5; i++) {
let stuObj = students[i];
let datas = `<h1>${stuObj.name}</h1>`
datas += `<p>${stuObj.track}</p>`
datas += `<p>${stuObj.achievements}</p>`
datas += `<p>${stuObj.points}</p>`
print(datas)
}
function print(arg) {
document.write(`<div> ${arg} </div>`)
}
why does students.lenght return undefined?
let students = [
{
name: "Kevin",
track: "JavaScript",
achievements: "123",
points: 3500,
},
{
name: "John",
track: "LUA",
achievements: "312",
points: 2121
}]
3 Answers

Gia Gabadadze
1,794 Pointsyou are using students.lenght you should use students.length
for (let i = 0; i < students.length; i++) {
let stuObj = students[i];
let datas = `<h1>${stuObj.name}</h1>`
datas += `<p>${stuObj.track}</p>`
datas += `<p>${stuObj.achievements}</p>`
datas += `<p>${stuObj.points}</p>`
print(datas)
}
function print(arg) {
document.write(`<div> ${arg} </div>`)
}

Alexander Davison
65,454 PointsTry students.length
(notice the 's')

Kevin Ohlsson
4,547 Pointsundefined
for (let i = 0; i < students.lenght; i++) {
let stuObj = students[i];
let datas = `<h1>${stuObj.name}</h1>`
datas += `<p>${stuObj.track}</p>`
datas += `<p>${stuObj.achievements}</p>`
datas += `<p>${stuObj.points}</p>`
print(datas)
}
function print(arg) {
document.write(`<div> ${arg} </div>`)
}
not misspell

John Gilmer
Courses Plus Student 1,806 PointsTry student.length

Kevin Ohlsson
4,547 PointsUncaught ReferenceError: student is not defined