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 JavaScript and the DOM (Retiring) Making Changes to the DOM Modifying Elements

Riley Egan
Riley Egan
7,255 Points

I'm unable to pass the second challenge of "Modifying Elements" in JavaScript and the DOM.

I've rewatched the videos multiple times and can't figure out how to pass the second test. I keep getting the error that test 1 fails whenever I try to pass test 2.

I've tried multiple ways of setting the value in set 1 and would love some help on how to do this in a way that passes both tests.

Thanks!

app.js
const input = document.querySelector('input');

let inputValue = input.value;

a.innerHTML = input.value;



//button.addEventListener('click', function() {
//  a.textContent = inputValue;
//})
index.html
<!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">'inputValue'</a>
        </div>
        <script src="app.js"></script>
    </body>
</html>

2 Answers

Neil McPartlin
Neil McPartlin
14,662 Points

Riley. You are nearly there.

1: In your first line, replace querty with query.

2: Although using inputVal in lines 1 & 3 would work in the wild, these challenges expect back the word they specified, so replace both with inputValue

Riley Egan
Riley Egan
7,255 Points

let inputVal = document.quertySelector('input').value;

const a = document.querySelector('a');

a.textContent = inputVal;