← Back to HTML DOM
Question 188
Add a Status Class Based on a Score
Add a Status Class Based on a Score
The div with id="result" has adata-scoreattribute. Read the score as a number: if it is 60 or higher, add the class "pass"; otherwise add the class "fail". Platform-Provided HTML (READ-ONLY):<div id="result" data-score="85">Score</div>Steps: 1. Read the number withparseInt(el.dataset.score). 2. Use anif/elseto decide which class to add. 3. Add the class withclassList.add().
Expected Output:
<div id="result" data-score="85" class="pass">Score</div>= newline. No newline after the last line.
Hints4 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.