JavaScript JavaScript and the DOM Getting a Handle on the DOM Selecting by Id

no comprendo muchacho

i do not understand how assign the button to the variable

var button;
var input;

button.addEventListener('click', () => {

var button = document.getElementById("sayPhrase");
<!DOCTYPE html>
    <title>Phrase Sayer</title>
    <p><input type="text" id="phraseText"></p>
    <p><button id="sayPhrase">Say Phrase</button></p>
    <script src="js/app.js"></script>

1 Answer

Steven Parker
Steven Parker
207,976 Points

It looks like you have the right code, but in the wrong place.

Just move your initialization up to the top line to replace the simple declaration initially provided.