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

Skip to content

Commit a77c001

Browse files
committed
Finished wesbos#17
1 parent c4b75c8 commit a77c001

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

17 - Sort Without Articles/index-START.html

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,33 @@
4444
<ul id="bands"></ul>
4545

4646
<script>
47-
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'];
47+
const bands = ['Rare Band', 'Bee Gees', 'The Whispers', 'Voyage', 'Shalamar', 'Dazz Band', 'Change', 'MFSB', 'Pieces of a Dream', 'The RAH Band', 'Supermax', 'El Coco', 'Raw Silk', 'The Electric Connection', 'DeBarge'];
4848

49+
function strip(bandName) {
50+
return bandName.replace(/^(the |el )/i, '').trim();
51+
}
4952

53+
// const sortedBands = bands.sort(function(a, b) {
54+
// // if (strip(a) > strip(b)) {
55+
// // return 1;
56+
// // } else {
57+
// // return -1;
58+
// // }
59+
60+
// return (strip(a) > strip(b) ? 1 : -1);
61+
// });
62+
63+
// const sortedBands = bands.sort((a, b) => {
64+
// return (strip(a) > strip(b) ? 1 : -1);
65+
// }
66+
67+
const sortedBands = bands.sort((a, b) => (strip(a) > strip(b) ? 1 : -1));
68+
69+
document.querySelector('#bands').innerHTML = sortedBands
70+
.map(band => `<li>${band}</li>`)
71+
.join('');
72+
73+
console.log(sortedBands);
5074
</script>
5175

5276
</body>

0 commit comments

Comments
 (0)