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 Looping through a jQuery collection

The follow code isn't working?

So, I have matched the code exactly as it appears in the video, to the best that I can tell:

$('a').each(function(index, link){ const url = $(link).attr('href'); $(link).parent().append('(${url})'); });

However she's getting the URL and I'm getting {url} what am I getting wrong?

2 Answers

Steven Parker
Steven Parker
231,261 Points

It looks like you're trying to use a template string, but template strings must be enclosed with accents (backticks) instead of single or double quotes.

  $(link).parent().append('(${url})');   // so instead of this...
  $(link).parent().append(`(${url})`);   // ... use THIS
Yuri Souza
Yuri Souza
9,518 Points

Thanks dude, i would've never realized that by myself

Oh giiz, I could tell the difference in the video. So that's the key under the ~ ` correct?