← Back to HTML DOM
Question 183
Increment a Counter
Increment a Counter
The span with id="counter" holds the number 5. Read it, add 1, and write the new value (6) back as its text. Platform-Provided HTML (READ-ONLY):<span id="counter">5</span>Steps: 1. Read the current text and convert it to a number withparseInt(). 2. Add 1 and assign the result back totextContent.
Expected Output:
<span id="counter">6</span>= newline. No newline after the last line.
Hints2 available
Sign in to use hintsTopics:
HTML DOM
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (clog, fn, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.