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

Why there isn't quotes surrounding li in this line of code ul.removeChild(li); ?

Why there isn't quotes surrounding li here? '''javascript ul.removeChild(li); ? '''

But for example here there are quotes. '''javascript let li = document.createElement('li'); '''

2 Answers

Hello. The reason why it doesn't have quotes is because you are defining the li here:

let li = document.createElement('li');

and you are using the li variable here:

ul.removeChild(li);

First, you define the variable li to "li" and use li as "li" in the other code.

Hope you understand.

Yes, thank you :-)

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,253 Points

You're passing in a variable as an argument to removeChild. You can't do this if you add quotes as what you'd be doing there is directly passing in a string! :-)