Last active
December 23, 2024 17:19
-
-
Save slivorezka/8a2c1ec19066311908a76afe29facb9c to your computer and use it in GitHub Desktop.
Human: Підрахунок кількості оцінок у класі
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const marks = []; | |
let studentCounter = 0; | |
document.querySelectorAll('.user-list .user-item').forEach(item => { | |
const badge = item.querySelectorAll('.mark .badge__item') | |
if (badge[0]) { | |
studentCounter++; | |
const mark = badge[0].textContent.replace(/\s+/g, ''); | |
if (marks[mark]) { | |
marks[mark].push(mark) | |
} else { | |
marks[mark] = [mark]; | |
} | |
} | |
}); | |
let message = 'Учнів в класі: ' + studentCounter + "\n"; | |
marks.forEach((value, index) => { | |
message += 'Оцінка: ' + index + ' — Кількість: ' + value.length + "\n"; | |
}); | |
alert(message); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment