Add a Status Class Based on a Score
hardQuestion 188The div with id="result" has a data-score attribute. 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 with parseInt(el.dataset.score).
2. Use an if/else to decide which class to add.
3. Add the class with classList.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.