Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Victor Nugraha
9,115 PointsWhy my code won't run?
Hi,
This is from JavaScript Object Challenge, Can anyone tell me why my code won't run?
Here is the link of my workspace : https://w.trhou.se/1m11va7k2p
Thanks Victor
1 Answer
Yuval Blass
18,134 PointsHi Victor,
I went through your workspace and your code is actually running correctly. I do have three suggestions:
- Indentation is really important and made our code looks more readable; so consider indenting you code blocks correctly.
- When the for loop founds the student, it should break the loop. It has performance advantages. So please add a break statement after you are calling the print function.
- When you add += to a variable it's best to define the type of the variable at first. so add
var message = "";(this will also cancel the undefined error).
Have a lovely day,
Yuval.