added counter app js project#14
Conversation
|
Hi @sandeepMcodeX , there is no Readme.md file in the folder |
There was a problem hiding this comment.
Pull Request Overview
This PR adds a new counter application project written in JavaScript. The application provides a simple interface for incrementing and decrementing a counter value with user-defined step amounts.
- Creates a functional counter app with increment/decrement buttons
- Implements custom step value input for flexible counting
- Includes reset functionality to restore default values
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| 30-counter-app/index.html | HTML structure with counter display, control buttons, and step input |
| 30-counter-app/script.js | JavaScript logic for counter operations and event handling |
| 30-counter-app/style.css | CSS styling for the counter interface with button animations |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| const resultValue = parseInt(outputValue.innerText); | ||
| const userInputValue = parseInt(userInput.value); | ||
| outputValue.innerText = resultValue - userInputValue; | ||
| }); | ||
|
|
||
| increaseButton.addEventListener('click', () => { | ||
| const resultValue = parseInt(outputValue.innerText); | ||
| const userInputValue = parseInt(userInput.value); |
There was a problem hiding this comment.
parseInt() returns NaN when the input is invalid or empty, which will cause the counter to display NaN. Consider using parseInt() with a fallback value or validating the input first.
| const resultValue = parseInt(outputValue.innerText); | |
| const userInputValue = parseInt(userInput.value); | |
| outputValue.innerText = resultValue - userInputValue; | |
| }); | |
| increaseButton.addEventListener('click', () => { | |
| const resultValue = parseInt(outputValue.innerText); | |
| const userInputValue = parseInt(userInput.value); | |
| const resultValue = Number.isNaN(parseInt(outputValue.innerText)) ? 0 : parseInt(outputValue.innerText); | |
| const userInputValue = Number.isNaN(parseInt(userInput.value)) ? 1 : parseInt(userInput.value); | |
| outputValue.innerText = resultValue - userInputValue; | |
| }); | |
| increaseButton.addEventListener('click', () => { | |
| const resultValue = Number.isNaN(parseInt(outputValue.innerText)) ? 0 : parseInt(outputValue.innerText); | |
| const userInputValue = Number.isNaN(parseInt(userInput.value)) ? 1 : parseInt(userInput.value); |
| const resultValue = parseInt(outputValue.innerText); | ||
| const userInputValue = parseInt(userInput.value); | ||
| outputValue.innerText = resultValue - userInputValue; | ||
| }); | ||
|
|
||
| increaseButton.addEventListener('click', () => { | ||
| const resultValue = parseInt(outputValue.innerText); | ||
| const userInputValue = parseInt(userInput.value); |
There was a problem hiding this comment.
parseInt() returns NaN when the input is invalid or empty, which will cause the counter to display NaN. Consider using parseInt() with a fallback value or validating the input first.
| const resultValue = parseInt(outputValue.innerText); | |
| const userInputValue = parseInt(userInput.value); | |
| outputValue.innerText = resultValue - userInputValue; | |
| }); | |
| increaseButton.addEventListener('click', () => { | |
| const resultValue = parseInt(outputValue.innerText); | |
| const userInputValue = parseInt(userInput.value); | |
| let resultValue = parseInt(outputValue.innerText); | |
| if (isNaN(resultValue)) resultValue = 0; | |
| let userInputValue = parseInt(userInput.value); | |
| if (isNaN(userInputValue)) userInputValue = 1; | |
| outputValue.innerText = resultValue - userInputValue; | |
| }); | |
| increaseButton.addEventListener('click', () => { | |
| let resultValue = parseInt(outputValue.innerText); | |
| if (isNaN(resultValue)) resultValue = 0; | |
| let userInputValue = parseInt(userInput.value); | |
| if (isNaN(userInputValue)) userInputValue = 1; |
| transition: all 0.1s; | ||
| -webkit-box-shadow: 0px 6px 0px #e62222; | ||
| -moz-box-shadow: 0px 6px 0px #e62222; | ||
| box-shadow: 0px 6px 0px #b20000; |
There was a problem hiding this comment.
Inconsistent box-shadow colors for the reset button. The webkit and moz prefixes use #e62222 while the standard property uses #b20000, creating visual inconsistencies across browsers.
| box-shadow: 0px 6px 0px #b20000; | |
| box-shadow: 0px 6px 0px #e62222; |
| -webkit-box-shadow: 0px 2px 0px #e62222; | ||
| -moz-box-shadow: 0px 2px 0px #e62222; | ||
| box-shadow: 0px 2px 0px #e62222; |
There was a problem hiding this comment.
Inconsistent box-shadow color for the reset button active state. The colors should match the inactive state pattern or use consistent colors across all three declarations.
No description provided.