Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4cb6751

Browse files
committed
finished JS Day wesbos#17
1 parent 5150fd7 commit 4cb6751

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

17 - Sort Without Articles/index-START.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,15 @@
4545

4646
<script>
4747
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'];
48+
const bandWrapper = document.querySelector('#bands');
4849

50+
function strip(bandName){
51+
return bandName.replace(/^(a |the |an )/i, '').trim()
52+
}
53+
54+
const bandsSorted = bands.sort((a,b) => strip(a) < strip(b) ? -1 : 1).map(band => `<li>${band}</li>`).join('')
55+
56+
bandWrapper.innerHTML = bandsSorted
4957

5058
</script>
5159

0 commit comments

Comments
 (0)