Skip to content

Commit 6ec5a7c

Browse files
committed
Completed Day #17
1 parent 0fee785 commit 6ec5a7c

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Sort Without Articles</title>
6+
</head>
7+
<body>
8+
9+
<style>
10+
body {
11+
margin: 0;
12+
font-family: sans-serif;
13+
background: url("https://source.unsplash.com/nDqA4d5NL0k/2000x2000");
14+
background-size: cover;
15+
display: flex;
16+
align-items: center;
17+
min-height: 100vh;
18+
}
19+
20+
#bands {
21+
list-style: inside square;
22+
font-size: 20px;
23+
background: white;
24+
width: 500px;
25+
margin: auto;
26+
padding: 0;
27+
box-shadow: 0 0 0 20px rgba(0, 0, 0, 0.05);
28+
}
29+
#bands li {
30+
border-bottom: 1px solid #efefef;
31+
padding: 20px;
32+
}
33+
#bands li:last-child {
34+
border-bottom: 0;
35+
}
36+
37+
a {
38+
color: #ffc600;
39+
text-decoration: none;
40+
}
41+
42+
</style>
43+
44+
<ul id="bands"></ul>
45+
46+
<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'];
48+
49+
const strip = bandName => bandName.replace(/^(a |the |an )/i, '').trim();
50+
51+
const sortedBands = bands.sort((a, b) => strip(a) > strip(b) ? 1 : -1);
52+
53+
document.querySelector('#bands').innerHTML = sortedBands.map(band => `<li>${band}</li>`).join('');
54+
55+
</script>
56+
57+
</body>
58+
</html>

0 commit comments

Comments
 (0)