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 DOM Scripting By Example Improving the Application Code Next Steps

Why doesn't this work???

I tried adding an alert when the list item's text content is blank, but it's not appearing for some reason.

Here is the link to a snapshot of my code:

https://w.trhou.se/sqeu62i89d

This line in particular:

    if (span.text == '') {
      alert('The guest you have added has no name');
    }

I have also tried span.textContent but it still doesn't work.

Why is this, and how can I fix it, I would really appreciate any help.

1 Answer

I switched index.html to

<script src="myscript.js"></script>

where that code is located and in the console found

myscript.js:80 Uncaught ReferenceError: span is not defined
    at HTMLUListElement.<anonymous> (myscript.js:80)

which it isn't.

What do you mean by "which it isn't," and how can I fix this.