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

Van Jordan
Van Jordan
3,350 Points

incorrect answers are leading cause of imposter syndrome!

??????????????????????????????????????

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() {
  // Write code here
  this.prepend('<input type="checkbox"/>');
});

1 Answer

Totally understandable! I usually find that when I am having issues with a challenge it is something silly that I am missing. Usually it's my syntax. I don't generally have a problem with the logical part of the challenges, which doesn't seem to be your issue either. I would definitely say it is your syntax that is the issue. I suggest looking at this forum post for the answer to your question. I don't want to take any credit away from those that have already helped others with the same issue.

https://teamtreehouse.com/community/inside-the-jquery-each-method-use-prepend-to-add-an-input-typecheckbox-to-the-beginning-of-each-list-item-2

Getting used to the syntax is something that comes with practice. So, I wouldn't say that you are an imposter, even though you may feel like it. I know I do all of the time. I just have to remember that the more I practice the less I have to look at the documentation and the better I get. I am sure it is/will be the same for you.

Best of luck to you!

Van Jordan
Van Jordan
3,350 Points

Thanks for the encouragement!