diff --git a/exercises/part1-selectors-and-events/index.js b/exercises/part1-selectors-and-events/index.js index 25a3025..016c4f6 100644 --- a/exercises/part1-selectors-and-events/index.js +++ b/exercises/part1-selectors-and-events/index.js @@ -16,30 +16,32 @@ Part 1: Set the variable below equal to the paragraph element representing the first test result. ==================== */ -let firstResult; +let firstResult = document.getElementById('result-1'); + /* ==================== Parts 2: Set the variable below equal to a collection of the paragraph elements representing the 2nd and 3rd results. ==================== */ -let secondAndThirdResults; +let secondAndThirdResults = document.getElementsByClassName('result result-2-3'); /* ==================== Parts 3: Set the variable below equal to a collection of the paragraph elements representing the all of the results. ==================== */ -let allResults; +/*let allResults = document.getElementsByClassName('result');*/ +let allResults = document.querySelectorAll('p'); /* ==================== Part 4: Add an event listener to the button in problem 4 that changes the button's own text to "I'm Clicked!" ==================== */ -let imClickedButton; +let imClickedButton = document.getElementById('im-clicked-button'); if (imClickedButton) { - imClickedButton.addEventListener('click', () => {}); + imClickedButton.addEventListener('click', () => {imClickedButton.textContent = "I'm Clicked!"}); } /* ==================== @@ -55,10 +57,15 @@ HINT: You may need some global state for this problem. let spanContainer = document.querySelector('#span-container'); spanContainer.appendChild(htmlToElement('0')); +/*reduce function? for loop?*/ +let num = 0; let addSpanButton; if (addSpanButton) { - addSpanButton.addEventListener('click', () => {}); + addSpanButton.addEventListener('click', () => { + num++; + spanContainer.appendChild(num); + }); } /* =====================