Skip to content

Commit e4ba526

Browse files
committed
complete wesbos#17
1 parent 8053d3f commit e4ba526

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

17 - Sort Without Articles/index-START.html

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
#bands {
2020
list-style: inside square;
21-
font-size: 20px;
21+
font-size: 12px;
2222
background: white;
2323
width: 500px;
2424
margin: auto;
@@ -43,8 +43,15 @@
4343
<ul id="bands"></ul>
4444

4545
<script>
46-
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'];
46+
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 = sortedBands.map(band => `<li>${band}</li>`).join('')
4855

4956
</script>
5057

0 commit comments

Comments
 (0)