Skip to content

Commit c7f1ec2

Browse files
committed
Exercise 17
1 parent 77c8193 commit c7f1ec2

File tree

2 files changed

+7
-65
lines changed

2 files changed

+7
-65
lines changed

17 - Sort Without Articles/index-START.html

Lines changed: 0 additions & 52 deletions
This file was deleted.

17 - Sort Without Articles/index-FINISHED.html renamed to 17 - Sort Without Articles/index.html

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,14 @@
4343
<ul id="bands"></ul>
4444

4545
<script>
46-
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'];
46+
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 list = document.querySelector('#bands');
4748

48-
function strip(bandName) {
49-
return bandName.replace(/^(a |the |an )/i, '').trim();
50-
}
51-
52-
const sortedBands = bands.sort((a, b) => strip(a) > strip(b) ? 1 : -1);
53-
54-
document.querySelector('#bands').innerHTML =
55-
sortedBands
56-
.map(band => `<li>${band}</li>`)
57-
.join('');
58-
59-
console.log(sortedBands);
49+
function strip(bandName) {
50+
return bandName.replace(/^(a |the |an )/i, '').trim();
51+
}
52+
const sortedBands = bands.sort((a, b) => strip(a) > strip(b) ? 1 : -1);
53+
list.innerHTML = sortedBands.map(band => `<li>${band}</li>`).join('');
6054

6155
</script>
6256

0 commit comments

Comments
 (0)