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 trialYohan Aton
1,738 PointsDrawing a blank on part 2 -
Hi, thanks for taking a sec.
Having trouble with the second part of the question.
I believe it's looking for the name of the tag, but I'm not understanding what the question is looking for as a solution. I tried ('last_name')[1] and ('span')[1] etc... each time it tells me the first answer is no longer correct.
Looked at mdn but still drawing a blank
Basically, just looking for the answer so I can understand it and move on.
Thanks so much for your help & patience!
var fullName = document.getElementById("full_name");
var lastName = document.getElementByTagName("last_name");
4 Answers
Michael Liendo
15,326 PointsHello!
Thanks for posting what you've tried, and that you've checked the documentation!
The correct answer is: var lastName = document.getElementsByTagName('span')[1];
note that there is an 's' in Elements, this is helpful to indicate that when you put in the tag name, in this case 'span', it captures all the items with that tag. From there is just a matter of selecting the one you want, in this case, the second one at index 1.
Hope that helps and happy coding!
andi mitre
Treehouse Guest TeacherHey Yohan,
Quite close..but for lastName it is asking for the second span element, so you would get all span elements and reference the second index.
var fullName = document.getElementById('full_name');
var lastName = document.getElementsByTagName('span')[1];
Cheers
Yohan Aton
1,738 PointsHi Andi!
Thanks so much for your reply.
I could swear I tried that and it didn't work... - maybe I had double quotes on the first line...?
In any event, got it now - Thank You!!!
Yohan Aton
1,738 PointsHi Michael,
Thanks so much for your reply.
I could swear I tried that and it didn't work...
- maybe I had double quotes on the first line...?
In any event, got it now - Thank You!!!
Yohan Aton
1,738 Points... Speed bump - see I missed the 's' as well.
Thanks for all the help!