Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript

Challenge task 1 of 2

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 app.js

var fullName; var lastName;

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>

6 Answers

Here is my answer. var fullName=document.getElementById("full_name"); var lastName=document.getElementsByClassName("last_name");

Thx and this 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.

Marcin Robert Kaźmierczak
Marcin Robert Kaźmierczak
33,570 Points

It should be

var fullName=document.getElementById("full_name"); 
var lastName=document.getElementsByTagName("span")[1];
Erik McClintock
Erik McClintock
45,783 Points

Ilyass,

Could you please post your code and the problem that you're having?

Erik

Erick, can you give me the solution of this chalenge The chalenge is say 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

the code of app.js

            <p>var fullName;
                   var lastName;
            </p>
            ```

and the code of index.html
 ```html
 <p>
<!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>
 </p>
Erik McClintock
Erik McClintock
45,783 Points

Ilyass,

I would be more than happy to help guide you towards the answer if you could provide the code that you've tried and what specifically you're stuck on regarding this challenge!

Erik

Michael Stopa
Michael Stopa
14,965 Points

Dear All, It looks like the second task is not passing. Any idea whay it might be?: var fullName=document.getElementById("full_name"); var lastName=document.getElementsByClassName("last_name");

Best, M

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