Skip to content

Commit c03dabb

Browse files
committed
17
1 parent 8600158 commit c03dabb

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

17 - Sort Without Articles/index-START.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@
4545
<script>
4646
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'];
4747

48+
function strip(bandName) {
49+
return bandName.replace(/^(a |the |an )/i, '').trim();
50+
}
51+
52+
const sortedBands = bands.sort((a, b) => strip(a) > strip(b) ? 1 : -1 );
53+
54+
document.querySelector('#bands').innerHTML =
55+
sortedBands
56+
.map(band => `<li>${band}</li>`)
57+
.join('');
4858

4959
</script>
5060

0 commit comments

Comments
 (0)