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

Skip to content

Commit c72fded

Browse files
author
Alexander Besse
committed
wesbos#17 Completed.
1 parent b0c7ccc commit c72fded

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

17 - Sort Without Articles/index-START.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@
4848
<script>
4949
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'];
5050

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

5259
</script>
5360

0 commit comments

Comments
 (0)