โ Back to HTML DOM
Question 148
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>
Topics:
HTML DOM
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท 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.