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 jQuery Basics Working with jQuery Collections The .each() method

I think treehouse is broken.

Bummer: SyntaxError: app.js: Unexpected token c (2:32)

My code works in VSC and I'm satisfying everything asked for in the challenge. I don't know what else it wants I think treehouse needs to modify this questions requirements for it to accept solutions that work so people like me aren't banging their heads for no reason.. Please fix this or someone tell me how I'm wrong. Thanks.

index.html
<!DOCTYPE html>
<html lang="en">
<head>
    <title>Document</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <h2>My Favorite Things</h2>

    <ul class="favorite-things">
        <li>Kittens</li>
        <li>Rainbows</li>
        <li>Unicorns</li>
        <li>Sprinkles</li>
    </ul>

    <script
    src="jquery-3.2.1.min.js"></script>
    <script src="app.js"></script>
</body>
</html>
app.js
$('.favorite-things li').each(function() {
  $(this).prepend('<input type='checkbox'>');
  });

1 Answer

Martin Balon
Martin Balon
43,651 Points

Hi Andrew, The error tells you that there is character "c" at line 2 position 32 that shouldn't be there. If you look at line 2 you can see that in your prepend method you are passing input as argument. This input is wrapped in single quotes and type of the input is wrapped in single quotes again. This means that you are passing a string '<input type='. Just change one set of single quotes to double quotes and it should work.

$('.favorite-things li').each(function() {
  $(this).prepend('<input type="checkbox">');
  });

You know I didn't know how to zero in on problems that way, that will help in the future. Thank you for the reply, I still think that it's treehouse's editor that's the problem here. I changed out quote marks several times trying to get one set to pass. It finally accepted something but I can't even remember which it was. The fact that they worked in VSC and not here is enough for me to just say it's treehouse's editor's fault, or the parameters of this task within it, and not my own.