Skip to content

Instantly share code, notes, and snippets.

@slivorezka
Last active December 23, 2024 17:19
Show Gist options
  • Save slivorezka/8a2c1ec19066311908a76afe29facb9c to your computer and use it in GitHub Desktop.
Save slivorezka/8a2c1ec19066311908a76afe29facb9c to your computer and use it in GitHub Desktop.
Human: Підрахунок кількості оцінок у класі
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