Skip to content

Added counter app in javascript challenges - #536

Open
Ishikaa03 wants to merge 1 commit into
sadanandpai:mainfrom
Ishikaa03:add-counter-app
Open

Added counter app in javascript challenges#536
Ishikaa03 wants to merge 1 commit into
sadanandpai:mainfrom
Ishikaa03:add-counter-app

Conversation

@Ishikaa03

@Ishikaa03 Ishikaa03 commented Mar 19, 2026

Copy link
Copy Markdown

Added a simple counter app using HTML, CSS, and JavaScript.

Features:

  • Increment and decrement functionality
  • Clean UI
  • Beginner-friendly implementation

Summary by CodeRabbit

  • New Features
    • Added a new Counter App that allows users to increment and decrement a numerical value using interactive buttons.
    • Displays real-time updates to the counter value with every button interaction.
    • Features a clean, centered user interface with styled buttons and responsive layout for an optimal user experience.

@netlify

netlify Bot commented Mar 19, 2026

Copy link
Copy Markdown

Deploy Preview for frontend-mini-challenges ready!

Name Link
🔨 Latest commit 6424983
🔍 Latest deploy log https://app.netlify.com/projects/frontend-mini-challenges/deploys/69bc4779fd3b930008e4f859
😎 Deploy Preview https://deploy-preview-536--frontend-mini-challenges.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Mar 19, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

A new Counter App feature is introduced with three files: an HTML page displaying a counter with increment and decrement buttons, JavaScript implementing state management and button functionality, and CSS styling for the interface layout and button appearance. Total 49 lines added across three new files.

Changes

Cohort / File(s) Summary
Counter App
apps/javascript/counter-app/index.html, apps/javascript/counter-app/script.js, apps/javascript/counter-app/style.css
New counter application with HTML markup, JavaScript logic for increment/decrement functions that update DOM state, and CSS styling for layout, button appearance, and centering.

Estimated Code Review Effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 bounces with joy
Count goes up with every click,
Button by button, fast and quick,
HTML holds the pretty view,
JavaScript makes counting true,
Styled with CSS, shiny and bright! ✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is largely incomplete against the required template, missing critical sections like issue number, code stack, and the required checklist items. Complete the PR description by adding the issue number, code stack, closing statement, and checking off relevant checklist items per the repository template.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Added counter app in javascript challenges' directly and clearly summarizes the main change—adding a new counter application to the JavaScript section.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Stylelint (17.4.0)
apps/javascript/counter-app/style.css

ConfigurationError: Could not find "stylelint-config-recess-order". Do you need to install the package or use the "configBasedir" option?
at getModulePath (file:///usr/local/lib/node_modules/stylelint/lib/utils/getModulePath.mjs:29:9)
at loadExtendedConfig (file:///usr/local/lib/node_modules/stylelint/lib/augmentConfig.mjs:241:21)
at extendConfig (file:///usr/local/lib/node_modules/stylelint/lib/augmentConfig.mjs:208:25)
at async augmentConfigBasic (file:///usr/local/lib/node_modules/stylelint/lib/augmentConfig.mjs:73:20)
at async augmentConfigFull (file:///usr/local/lib/node_modules/stylelint/lib/augmentConfig.mjs:126:24)
at async getConfigForFile (file:///usr/local/lib/node_modules/stylelint/lib/getConfigForFile.mjs:102:26)
at async resolveOptionValue (file:///usr/local/lib/node_modules/stylelint/lib/utils/resolveOptionValue.mjs:27:24)
at async standalone (file:///usr/local/lib/node_modules/stylelint/lib/standalone.mjs:202:19)


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

You can customize the high-level summary generated by CodeRabbit.

Configure the reviews.high_level_summary_instructions setting to provide custom instructions for generating the high-level summary.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (2)
apps/javascript/counter-app/index.html (1)

4-7: Add viewport metadata for better mobile rendering.

This keeps scaling predictable on mobile devices.

Suggested fix
   <head>
     <meta charset="UTF-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
     <title>Counter App</title>
     <link rel="stylesheet" href="style.css" />
   </head>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/javascript/counter-app/index.html` around lines 4 - 7, Add a responsive
viewport meta tag to index.html to ensure predictable mobile scaling by
inserting a meta element like the standard viewport declaration (<meta
name="viewport" content="width=device-width, initial-scale=1" />) into the head
alongside the existing <meta charset="UTF-8" /> and before the <title> or <link
rel="stylesheet" href="style.css" />; update the head content in the file so
mobile devices render/layout consistently.
apps/javascript/counter-app/style.css (1)

13-19: Add explicit keyboard focus styling for buttons.

A dedicated :focus-visible style improves accessibility consistency.

Suggested fix
 button {
   padding: 10px 20px;
   margin: 5px;
   font-size: 18px;
   border-radius: 8px;
   cursor: pointer;
 }
+
+button:focus-visible {
+  outline: 3px solid `#1d4ed8`;
+  outline-offset: 2px;
+}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/javascript/counter-app/style.css` around lines 13 - 19, Add explicit
keyboard focus styling for interactive buttons by extending the existing button
rules: add a :focus-visible selector for button to apply a clear, high-contrast
outline or visible box-shadow (e.g., 2-3px solid or offset shadow) and
sufficient focus ring color, plus a :focus fallback for browsers without
:focus-visible; keep cursor and existing styles and avoid changing layout by
using outline-offset or box-shadow rather than changing border or padding.
Target the existing button selector and add button:focus-visible (and
button:focus fallback) to improve keyboard accessibility.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/javascript/counter-app/index.html`:
- Around line 11-14: The count display (element with id "count") and the
symbol-only buttons need accessibility updates: add an appropriate live region
attribute (e.g., aria-live="polite" and role="status" or aria-atomic="true") to
the "count" element so screen readers announce changes when
increment()/decrement() updates it, and give the "+" and "−" buttons explicit
accessible names (e.g., aria-label="Increment count" and aria-label="Decrement
count" or associate hidden text via aria-labelledby) so the increment() and
decrement() buttons are announced meaningfully by assistive tech.

In `@apps/javascript/counter-app/script.js`:
- Around line 3-11: Both event handlers (increment() and decrement()) duplicate
DOM lookup and will throw if document.getElementById('count') is null; refactor
by obtaining the element once into a local variable (e.g., const countEl =
document.getElementById('count')) inside each function (or higher scope), check
that countEl exists before mutating, and then update its innerText after
adjusting the shared count variable; replace repeated
document.getElementById('count') calls in increment() and decrement() with this
guarded reference to avoid duplication and runtime errors.

In `@apps/javascript/counter-app/style.css`:
- Around line 1-7: The body rule uses the static viewport unit height:100vh
which can mis-size on mobile; update the body selector (body { ... }) to use
dynamic viewport units—replace height: 100vh with min-height: 100dvh (or height:
100dvh) and keep height: 100vh as a fallback above it for older browsers so
centering remains correct across mobile browser chrome changes.

---

Nitpick comments:
In `@apps/javascript/counter-app/index.html`:
- Around line 4-7: Add a responsive viewport meta tag to index.html to ensure
predictable mobile scaling by inserting a meta element like the standard
viewport declaration (<meta name="viewport" content="width=device-width,
initial-scale=1" />) into the head alongside the existing <meta charset="UTF-8"
/> and before the <title> or <link rel="stylesheet" href="style.css" />; update
the head content in the file so mobile devices render/layout consistently.

In `@apps/javascript/counter-app/style.css`:
- Around line 13-19: Add explicit keyboard focus styling for interactive buttons
by extending the existing button rules: add a :focus-visible selector for button
to apply a clear, high-contrast outline or visible box-shadow (e.g., 2-3px solid
or offset shadow) and sufficient focus ring color, plus a :focus fallback for
browsers without :focus-visible; keep cursor and existing styles and avoid
changing layout by using outline-offset or box-shadow rather than changing
border or padding. Target the existing button selector and add
button:focus-visible (and button:focus fallback) to improve keyboard
accessibility.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fec28bfb-7611-4542-bccb-50a3813239e6

📥 Commits

Reviewing files that changed from the base of the PR and between 1418a13 and 6424983.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (3)
  • apps/javascript/counter-app/index.html
  • apps/javascript/counter-app/script.js
  • apps/javascript/counter-app/style.css

Comment on lines +11 to +14
<h2 id="count">0</h2>

<button onclick="increment()">+</button>
<button onclick="decrement()">-</button>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Improve accessibility for dynamic count and symbol-only buttons.

Add live-region semantics to the counter and explicit labels for +/- buttons.

Suggested fix
-      <h2 id="count">0</h2>
+      <h2 id="count" role="status" aria-live="polite" aria-atomic="true">0</h2>
 
-      <button onclick="increment()">+</button>
-      <button onclick="decrement()">-</button>
+      <button onclick="increment()" aria-label="Increment counter">+</button>
+      <button onclick="decrement()" aria-label="Decrement counter">-</button>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<h2 id="count">0</h2>
<button onclick="increment()">+</button>
<button onclick="decrement()">-</button>
<h2 id="count" role="status" aria-live="polite" aria-atomic="true">0</h2>
<button onclick="increment()" aria-label="Increment counter">+</button>
<button onclick="decrement()" aria-label="Decrement counter">-</button>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/javascript/counter-app/index.html` around lines 11 - 14, The count
display (element with id "count") and the symbol-only buttons need accessibility
updates: add an appropriate live region attribute (e.g., aria-live="polite" and
role="status" or aria-atomic="true") to the "count" element so screen readers
announce changes when increment()/decrement() updates it, and give the "+" and
"−" buttons explicit accessible names (e.g., aria-label="Increment count" and
aria-label="Decrement count" or associate hidden text via aria-labelledby) so
the increment() and decrement() buttons are announced meaningfully by assistive
tech.

Comment on lines +3 to +11
function increment() {
count++;
document.getElementById('count').innerText = count;
}

function decrement() {
count--;
document.getElementById('count').innerText = count;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Avoid repeated DOM queries and guard against missing #count.

Both handlers duplicate update logic and can throw if #count is not found.

Suggested fix
 let count = 0;
+const countElement = document.getElementById('count');
+
+function renderCount() {
+  if (!countElement) return;
+  countElement.innerText = String(count);
+}
 
 function increment() {
   count++;
-  document.getElementById('count').innerText = count;
+  renderCount();
 }
 
 function decrement() {
   count--;
-  document.getElementById('count').innerText = count;
+  renderCount();
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/javascript/counter-app/script.js` around lines 3 - 11, Both event
handlers (increment() and decrement()) duplicate DOM lookup and will throw if
document.getElementById('count') is null; refactor by obtaining the element once
into a local variable (e.g., const countEl = document.getElementById('count'))
inside each function (or higher scope), check that countEl exists before
mutating, and then update its innerText after adjusting the shared count
variable; replace repeated document.getElementById('count') calls in increment()
and decrement() with this guarded reference to avoid duplication and runtime
errors.

Comment on lines +1 to +7
body {
font-family: Arial;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Use dynamic viewport height to avoid mobile centering glitches.

height: 100vh can mis-size on mobile when browser chrome expands/collapses. Prefer dynamic viewport units.

Suggested fix
 body {
   font-family: Arial;
   display: flex;
   justify-content: center;
   align-items: center;
-  height: 100vh;
+  min-height: 100dvh;
+  margin: 0;
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
body {
font-family: Arial;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
body {
font-family: Arial;
display: flex;
justify-content: center;
align-items: center;
min-height: 100dvh;
margin: 0;
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/javascript/counter-app/style.css` around lines 1 - 7, The body rule uses
the static viewport unit height:100vh which can mis-size on mobile; update the
body selector (body { ... }) to use dynamic viewport units—replace height: 100vh
with min-height: 100dvh (or height: 100dvh) and keep height: 100vh as a fallback
above it for older browsers so centering remains correct across mobile browser
chrome changes.

@sadanandpai

Copy link
Copy Markdown
Owner

We already have the counter app. Is this different
https://sadanandpai.github.io/frontend-mini-challenges/javascript/src/challenges/counter/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants