Skip to content

Commit c53bb5d

Browse files
committed
Ex17 - Sort without articles
1 parent 0210fa6 commit c53bb5d

File tree

3 files changed

+82
-0
lines changed

3 files changed

+82
-0
lines changed

.eslintrc.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,8 @@ module.exports = {
7272
//'space-before-function-paren': ['warn', 'never'],
7373
'space-in-parens': ['warn', 'never'],
7474
'yoda': ['warn', 'never'],
75+
76+
//ES6
77+
'arrow-body-style': ['error', 'as-needed']
7578
}
7679
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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+
font-family: sans-serif;
12+
background: url("https://source.unsplash.com/nDqA4d5NL0k/2000x2000");
13+
background-size: cover;
14+
display: flex;
15+
align-items: center;
16+
min-height: 100vh;
17+
}
18+
19+
#bands {
20+
list-style: inside square;
21+
font-size: 20px;
22+
background: white;
23+
width: 500px;
24+
margin: auto;
25+
padding: 0;
26+
box-shadow: 0 0 0 20px rgba(0, 0, 0, 0.05);
27+
}
28+
#bands li {
29+
border-bottom: 1px solid #efefef;
30+
padding: 20px;
31+
}
32+
#bands li:last-child {
33+
border-bottom: 0;
34+
}
35+
36+
a {
37+
color: #ffc600;
38+
text-decoration: none;
39+
}
40+
41+
</style>
42+
43+
<ul id="bands"></ul>
44+
45+
<script src="script.js" charset="utf-8"></script>
46+
47+
</body>
48+
</html>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
'use strict';
2+
3+
const bands = ['The Plot in You', 'The Devil Wears Prada', 'Pierce the Veil', 'Norma Jean', 'The Bled', 'Say Anything', 'The Midway State',
4+
'We Came as Romans', 'Counterparts', 'Oh, Sleeper', 'A Skylit Drive', 'Anywhere But Here', 'An Old Dog', 'YOLO brothers'];
5+
6+
7+
// const forbidden = ['a', 'an', 'the', 'A', 'An', 'The'];
8+
//
9+
// function cleanWord(str) {
10+
// const firstWord = str.split(' ')[0];
11+
// if (forbidden.includes(firstWord)) {
12+
// const regexp = new RegExp(firstWord);
13+
// return str.replace(regexp, '').substr(1);
14+
// }
15+
// return str;
16+
// }
17+
18+
function strip(word) {
19+
return word.replace(/^a |an |the /i, '');
20+
}
21+
22+
bands.sort((word1, word2) => strip(word1) > strip(word2) ? 1 : -1);
23+
24+
console.log(bands);
25+
26+
27+
function renderBands(bands) {
28+
return bands.map(b => `<li>${b}</li>`).join('');
29+
}
30+
31+
document.querySelector('#bands').innerHTML = renderBands(bands);

0 commit comments

Comments
 (0)