[Javascript2] we have a list that's sorted as desired! :)

This commit is contained in:
Nicola Clark 2025-04-06 22:33:30 -05:00
parent 10a009f630
commit 601020f5f5
Signed by: nicola
GPG Key ID: BEF8036296D094BF
2 changed files with 13 additions and 2 deletions

View File

@ -48,5 +48,14 @@ function returnArticles(band) {
return '???';
}
const sortedBands = bands.map(removeArticles).sort().map(returnArticles);
console.log(sortedBands);
const bandsList = document.getElementById('bands');
bands
.map(removeArticles)
.sort()
.map(returnArticles)
.forEach((band) => {
const bandListItem = document.createElement('li');
bandListItem.textContent = band;
bandsList.appendChild(bandListItem);
});

View File

@ -14,6 +14,8 @@ New elements:
New attributes:
New JS:
* JSDoc - I missed having type-based completions in VScode from TypeScript
* Creating a DOM element - not really new, I just forgot how to and had to
double-check on W3Schools
-->
<html lang="en">
<head>