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 trialRiley Goodman
3,603 PointsStep 1 is no longer passing... but it is?
I pass the first step, then submit the second. Then it says step 1 is no longer passing, so I go back and re-submit the first step without changing anything, and it passes. Both steps look correct to me. Also, no matter what I put into the second step, even if it's just a bunch of gibberish, It does the same thing.
let inputValue = linkName.value;
<!DOCTYPE html>
<html>
<head>
<title>DOM Manipulation</title>
</head>
<link rel="stylesheet" href="style.css" />
<body>
<div id="content">
<label>Link Name:</label>
<input type="text" id="linkName">
<a id="link" href="https://teamtreehouse.com"></a>
</div>
<script src="app.js"></script>
</body>
</html>
Riley Goodman
3,603 PointsTask 2 answer: let inputValue = link.textContent;
I've also tried let inputValue = a.textContent; and some other stuff, but no matter what I do, it just tells me step 1 is no longer passing.
1 Answer
Steven Parker
231,269 PointsIn mutliple-task challenges, each step builds on the previous one. It's important to leave the task 1 line as it is, and add the code for task 2 after it on a separate line.
And the task 2 instructions say, "Set the text content of the a tag to be the value stored in the variable inputValue." so this time the inputValue will be on the right side of the assignment.
Nate Baker
17,247 PointsSteven or Riley,
Thanks to your conversation, I arrived at the right answer: link.textContent = inputValue.
However, I'm still confused. How is link.textContent = inputValue different than Riley's (and mine) original answer of let inputValue = link.textContent? Aren't both statements setting inputValue to a new value?
Steven Parker
231,269 PointsOnly "let inputValue = link.textContent
" sets inputValue to a new value, but that's not what task 2 asks for.
But "link.textContent = inputValue
" accomplishes the task 2 instructions to "Set the text content of the a tag...".
In an assignment statement (indicated by the "=" operator), only the item on the left side is changed. So the line created for task 1 sets inputValue, and the line for task 2 uses that value to set something else.
Steven Parker
231,269 PointsSteven Parker
231,269 PointsI see your task 1 code, but what is your complete answer for task 2?