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) Getting a Handle on the DOM Selecting by Id

matthew pullen
matthew pullen
2,410 Points

I keep getting errors in tests that Task 1 is no longer passing when doing tests

Task 1 was setting button let button = document.getElementById('sayPhrase'); (This code passed ok)

Task 2 was setting input as well let button = document.getElementById('sayPhrase'); let input = document.getElementByid('phraseText'); (This now says task 1 is not passing)

I am confused... What am I doing wrong?

js/app.js
let button = document.getElementById('sayPhrase');
let input = document.getElementByid('phraseText');

button.addEventListener('click', () => {
  alert(input.value);
});
index.html
<!DOCTYPE html>
<html>
  <head>
    <title>Phrase Sayer</title>
  </head>
  <body>
    <p><input type="text" id="phraseText"></p>
    <p><button id="sayPhrase">Say Phrase</button></p>
    <script src="js/app.js"></script>
  </body>
</html>

2 Answers

Brodey Newman
Brodey Newman
10,962 Points

Hey Matthew,

Looking at your code I see you didn't capitalize the 'I' in:

document.getElementByid('phraseText');

Do that and it should work.

Hope this helps :)

matthew pullen
matthew pullen
2,410 Points

Thanks Brody... I guess when I retyped I got it right. Thanks for taking a look though;-)

matthew pullen
matthew pullen
2,410 Points

I deleted everything and retyped it for the second task and it worked. Looks like something is changing in the test window from one task to another... I am going to contact support.

M.