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

JavaScript JavaScript Loops, Arrays and Objects Tracking Multiple Items with Arrays Useful Array Methods

Brian Foley
Brian Foley
8,440 Points

My code isn't working :(

Unfortunately I can't figure out why the program doesn't run when I preview the workspace. Here's what it looks like for me:

screenshot

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! This may sound silly, but make sure you've saved your file. In the picture provide here, the file isn't saved as denoted by the orange circle. If it's still not working, you might try including a snapshot to your workspace so we can look at the entire project. :sparkles:

4 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! You have an error on this line:

 print( 'Nope, we don't have any ' + search + ', sorry'); 

Because you use an apostrophe inside the string, it believes that the apostrophe in "don't" is actually the end of the string. Try this instead:

 print( "Nope, we don't have any " + search + ', sorry'); 

Hope this helps! :sparkles:

Hi Brian,

You have a problem with your quotes in this line

print( 'Nope, we don't have any ' + search + ', sorry');

You're enclosing the string in single quotes but you also have a literal single quote within your string.

You could either escape the single quote by putting a backslash in front of it

'Nope, we don\'t have any '

Or enclose the string in double quotes so that you don't have to escape single quotes within it.

"Nope, we don't have any "
Brian Foley
Brian Foley
8,440 Points

Thanks Jennifer. It was saved, I just hit the spacebar somewhere before taking the screengrab. Here's the snapshot: https://w.trhou.se/0g3maylssz

Brian Foley
Brian Foley
8,440 Points

Oh man I can't believe I didn't see that. Thanks so much!