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

Skip to content

Commit a94b5a2

Browse files
committed
Added Sort Without Articles (wesbos#17)
1 parent 8a3d2cf commit a94b5a2

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

17 - Sort Without Articles/index-START.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@
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'];
4848

49+
const re = /a |an |the /i;
50+
const sortedBands = bands.sort(
51+
(a, b) => (a.replace(re, '') >= b.replace(re, '') ? 1 : -1)
52+
);
53+
54+
document.getElementById('bands').innerHTML = sortedBands.map(
55+
(b) => `<li>${b}</li>`
56+
).join('');
57+
4958

5059
</script>
5160

0 commit comments

Comments
 (0)