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 Interactive Web Pages with JavaScript Selecting Elements and Adding Events with JavaScript Selecting Elements

Amber Cookman
Amber Cookman
12,662 Points

Am I missing something in this Challenge Task?

Hello folks!

I am working on this Challenge Task in the Interactive Web Pages with JavaScript course, and can’t seem to figure out if I am actually entering something wrong or if I’ve encountered a bug. As far as I can tell from comparing the code I submitted in this challenge to what I successfully used and was learning in the previous video, there shouldn’t be an issue? Am I just under-caffeinated? ^.^ Figured I'd ask here in case my eyes are just missing something, before emailing support. Thanks in advance for your help!

Challenge Task 1 of 2: Select the H1 tag with the id of full_name and assign it to the variable fullName on line 1. Take a look in the index.html to see the structure of the document

Code beginnings that I was given to add to:

var fullName;
var lastName;

My answer:

var fullName = document.getElementById("full_name");
var lastName;

Result: Well done! You're doing great!

Challenge Task 2 of 2: Select the second SPAN element on the page and assign it to the variable lastName on line 2. Take a look in the index.html to see the structure of the document.

Same HTML as before

My answer:

var fullName = document.getElementById("full_name");
var lastName = document.getElementByTagName("span")[1];

Result: Oops! It looks like Task 1 is no longer passing.

app.js
var fullName = document.getElementById("full_name");
var lastName = document.getElementByTagName("span")[1];
index.html
<!DOCTYPE html>
<html>
<head></head>
<body>
<h1 id="full_name"><span class="first_name">Andrew</span> <span class="last_name">Chalkley</span></h1>

<script src="app.js"></script>
</body>
</html>

1 Answer

Amber Cookman
Amber Cookman
12,662 Points

Solved! I was just hungry. :D

I forgot the s in document.getElement*s*ByTagName() and had no problems after correcting!