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

Skip to content

Commit f2c45d8

Browse files
committed
wesbos#17 done!
1 parent a174a1b commit f2c45d8

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

17 - Sort Without Articles/index-START.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,20 @@
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+
let articles = new Set();
52+
articles.add('The');
53+
articles.add('An');
54+
articles.add('A');
5155

56+
let sortedBands = bands.sort((a, b) => {
57+
let aArr = articles.has(a.split(' ')[0]) ? a.split(' ')[1] : a.split(' ')[0];
58+
let bArr = articles.has(b.split(' ')[0]) ? b.split(' ')[1] : b.split(' ')[0];
59+
return aArr < bArr ? -1 : 1;
60+
})
61+
62+
document.querySelector('#bands').innerHTML = sortedBands
63+
.map(band => `<li>${band}</li>`)
64+
.join('')
5265
</script>
5366

5467
</body>

0 commit comments

Comments
 (0)