This is a short question which only requires one state variable, which is the number of times the button has been clicked (count
). Attach a 'click'
event listener to the <button>
and each time it is clicked, increment the count
value and update the text with that value.
Since only the count needs to change, we can use a <span>
to target the count text and update its textContent
whenever a click event is fired.
Want to grow in your front end skills? Learn them the right way — build apps step-by-step while referencing best practices from Senior engineers.
Want to grow in your front end skills? Learn them the right way — build apps step-by-step while referencing best practices from Senior engineers.
Note: This is a short warm up question meant to help you familiarize with the coding workspace. Actual UI coding interview questions will be more complicated.
Make the text within the button display the number of times the button has been clicked.
Want to grow in your front end skills? Learn them the right way — build apps step-by-step while referencing best practices from Senior engineers.
This is a short question which only requires one state variable, which is the number of times the button has been clicked (count
). Attach a 'click'
event listener to the <button>
and each time it is clicked, increment the count
value and update the text with that value.
Since only the count needs to change, we can use a <span>
to target the count text and update its textContent
whenever a click event is fired.
Want to grow in your front end skills? Learn them the right way — build apps step-by-step while referencing best practices from Senior engineers.
console.log()
statements will appear here.