2025-04-06 22:19:39 -05:00
|
|
|
const bands = [
|
|
|
|
'The Plot in You',
|
|
|
|
'The Devil Wears Prada',
|
|
|
|
'Pierce the Veil',
|
|
|
|
'Norma Jean',
|
|
|
|
'The Bled',
|
|
|
|
'Say Anything',
|
|
|
|
'The Midway State',
|
|
|
|
'We Came as Romans',
|
|
|
|
'Counterparts',
|
|
|
|
'Oh, Sleeper',
|
|
|
|
'A Skylit Drive',
|
|
|
|
'Anywhere But Here',
|
|
|
|
'An Old Dog',
|
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes articles from a band name
|
|
|
|
* @param {string} band band name to remove articles from
|
|
|
|
* @returns {string} the band name with articles removed
|
|
|
|
*/
|
|
|
|
function removeArticles(band) {
|
2025-04-06 22:27:29 -05:00
|
|
|
if (band.substring(0, 4) === 'The ') {
|
2025-04-06 22:19:39 -05:00
|
|
|
return band.substring(4);
|
2025-04-06 22:27:29 -05:00
|
|
|
} else if (band.substring(0, 2) === 'A ') {
|
2025-04-06 22:19:39 -05:00
|
|
|
return band.substring(2);
|
2025-04-06 22:27:29 -05:00
|
|
|
} else if (band.substring(0, 3) === 'An ') {
|
2025-04-06 22:19:39 -05:00
|
|
|
return band.substring(3);
|
|
|
|
}
|
|
|
|
|
|
|
|
return band;
|
|
|
|
}
|
|
|
|
|
2025-04-06 22:28:46 -05:00
|
|
|
/**
|
|
|
|
* Reinserts articles into a band name
|
|
|
|
* @param {string} band band name to reinsert the article
|
|
|
|
* @returns {string} the band name with the article reinserted (if applicable)
|
|
|
|
*/
|
|
|
|
function returnArticles(band) {
|
|
|
|
for (const originalBand of bands) {
|
|
|
|
if (originalBand.endsWith(band)) {
|
|
|
|
return originalBand;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// we shouldn't end up here; every band with an article removed should have a
|
|
|
|
// corresponding original band name.
|
|
|
|
return '???';
|
|
|
|
}
|
|
|
|
|
2025-04-06 22:33:30 -05:00
|
|
|
const bandsList = document.getElementById('bands');
|
|
|
|
|
|
|
|
bands
|
|
|
|
.map(removeArticles)
|
|
|
|
.sort()
|
|
|
|
.map(returnArticles)
|
|
|
|
.forEach((band) => {
|
|
|
|
const bandListItem = document.createElement('li');
|
|
|
|
bandListItem.textContent = band;
|
|
|
|
bandsList.appendChild(bandListItem);
|
|
|
|
});
|