Skip to content

Commit 3fed010

Browse files
committed
day 18
1 parent 6d9f847 commit 3fed010

File tree

3 files changed

+70
-1
lines changed

3 files changed

+70
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,5 @@ Motivate yourself to code daily till 30 days, and see the magic!
3333
| [Day 14](./each%20day%20build%20day!/Day%14/) | [Key sequence detection](./each%20day%20build%20day!/Day%2014/) | [demo]() | [Takeaways](./each%20day%20build%20day!/Day%2014/README.md/) |
3434
| [Day 15](./each%20day%20build%20day!/Day%15/) | [Scrolling IN effects](./each%20day%20build%20day!/Day%2015/) | [demo]() | [Takeaways](./each%20day%20build%20day!/Day%2015/README.md/) |
3535
| [Day 16](./each%20day%20build%20day!/Day%16/) | [Reference vs copy](./each%20day%20build%20day!/Day%2016/) | [demo]() | [Takeaways](./each%20day%20build%20day!/Day%2016/README.md/) |
36-
| [Day 17](./each%20day%20build%20day!/Day%17/) | [Mouseover Shadow](./each%20day%20build%20day!/Day%2017/) | [demo]() | [Takeaways](./each%20day%20build%20day!/Day%2017/README.md/) |
36+
| [Day 17](./each%20day%20build%20day!/Day%17/) | [Mouseover Shadow](./each%20day%20build%20day!/Day%2017/) | [demo]() | [Takeaways](./each%20day%20build%20day!/Day%2017/README.md/) |
37+
| [Day 18](./each%20day%20build%20day!/Day%18/) | [Custom sorting names](./each%20day%20build%20day!/Day%2018/) | [demo]() | [Takeaways](./each%20day%20build%20day!/Day%2018/README.md/) |

each day build day!/Day 18/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Sorting without A/AN/THE
2+
3+
- Simple task to sort names using only the noun and not the articles
4+
5+
# challenges
6+
- sort
7+
- trim

each day build day!/Day 18/index.html

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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+
30+
#bands li {
31+
border-bottom: 1px solid #efefef;
32+
padding: 20px;
33+
}
34+
35+
#bands li:last-child {
36+
border-bottom: 0;
37+
}
38+
39+
a {
40+
color: #00fff2;
41+
text-decoration: none;
42+
}
43+
44+
</style>
45+
46+
<ul id="bands"></ul>
47+
48+
<script>
49+
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', ];
50+
51+
function stripping(str){
52+
return str.replace(/^(a |an |the )/i,'').trim()
53+
}
54+
55+
const sortedNames = bands.sort((a,b)=> stripping(a) > stripping(b));
56+
document.querySelector('#bands').innerHTML = sortedNames
57+
.map(band => `<li>${band}</li>`).join('');
58+
</script>
59+
60+
</body>
61+
</html>

0 commit comments

Comments
 (0)