Problem
Create a Lightning Web Component (LWC) to implement a counter.
Complete the provided practice example to implement two lightning buttons, which can increase/decrease the counter and display it on the screen.
Instructions
- Use 'lightning-button tag' to display buttons on the screen.
- Use a paragraph '<p>' tag with inner text as the counter by using lwc data binding.
- When the increase button is clicked, increment the counter by one. The counter cannot exceed a maximum value of 10, regardless of the number of times it is clicked.
- When the decrease button is clicked, decrement the counter by one. The counter cannot go below a minimum value of zero, regardless of the number of times it is clicked.
Sample output
Note : This exercise introduces you to creating a simple LWC component to change the value of a javascript variable from a button 'onchange' event handler. Focus on meeting the requirements, and feel free to validate your code using the execute button.
Refer to the official LWC documentation link for more details on data binding in LWC.
To learn more about lightning web components, click here to visit the lightning web components developers guide