Skip to content

Commit ea94528

Browse files
committed
day 17
1 parent 0d41939 commit ea94528

File tree

7 files changed

+50
-124
lines changed

7 files changed

+50
-124
lines changed

14-reference-copying/style.css

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

15-localStorage/style.css

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

16-text-shadow/style.css

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

17-sorting-without-articles/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Sorting Band Names without articles
2+
Watch this challenge live in [codepen](https://codepen.io/pouyio/full/WOOrOV/).

17-sorting-without-articles/app.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
window.onload = () => {
2+
3+
const bands = ['My Chemical Romance', 'The Anchor', 'We Came as Romans', 'I See Stars', 'Architects', 'Bring me the Horizon', 'Our Last Night', 'Enter Shikari', 'My Enemies & I', 'Saosin', 'Of Mice & Men'];
4+
5+
const strip = (bandName) => bandName.replace(/^(a |the | my)/i, '').trim();
6+
7+
const sortedBands = bands.sort((a,b) => ( strip(a) > strip(b))? 1: -1);
8+
9+
document.querySelector('.bands').innerHTML = sortedBands.map(e => `<li>${e}</li>`).join('');
10+
11+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Sorting Band Names without articles</title>
6+
<style media="screen">
7+
body{
8+
font-family: sans-serif;
9+
font-size: 1.8em;
10+
color: #383838;
11+
min-height: 100vh;
12+
margin: 0;
13+
padding: 1em;
14+
box-sizing: border-box;
15+
background-color: #e7e4e4;
16+
display: flex;
17+
flex-direction: column;
18+
justify-content: space-around;
19+
align-items: center;
20+
}
21+
h1 {
22+
text-align: center;
23+
}
24+
</style>
25+
</head>
26+
<body>
27+
<h1>Sorted Bands<br>
28+
<code>ignoring (a | the | my)</code>
29+
</h1>
30+
<ul class="bands">
31+
<li>Loading...</li>
32+
</ul>
33+
<script type="text/javascript" src="./app.js">
34+
</script>
35+
</body>
36+
</html>

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ My goal is simply to learn the basics by doing many simple things rather than st
2121
14. [x] [JavaScript References vs. Copying](./14-reference-copying) - [Codepen](https://codepen.io/pouyio/pen/wegbpP)
2222
15. [x] [LocalStorage](./15-localStorage) - [Codepen](https://codepen.io/pouyio/full/XgRpOd/)
2323
16. [x] [CSS Text Shadow Mouse Move Effect](./16-text-shadow) - [Codepen](https://codepen.io/pouyio/full/mwweaq/)
24-
17. [ ] Sort Without Articles
24+
17. [x] [Sort Without Articles](./17-sorting-without-articles) - [Codepen](https://codepen.io/pouyio/full/WOOrOV/)
2525
18. [ ] Adding Up Times with Reduce
2626
19. [ ] Webcam Fun
2727
20. [ ] Speech Detection

0 commit comments

Comments
 (0)