Skip to content

Commit 397c8ff

Browse files
authored
Merge pull request ironhack-labs#832 from FTWD-APR-2020/master
MIAMI FTWD - Niko Tzikas
2 parents 4f13452 + 3c64759 commit 397c8ff

File tree

3 files changed

+152
-1
lines changed

3 files changed

+152
-1
lines changed

index.html

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
7+
<title>Document</title>
8+
<link rel="stylesheet" href="styles.css" />
9+
</head>
10+
11+
<body>
12+
<h2>Welcoem to Tuesday</h2>
13+
<p>ANything i type</p>
14+
</body>
15+
16+
17+
18+
<script src="./js/index.js"></script>
19+
</html>

js/index.js

Lines changed: 129 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,135 @@
11
// Iteration 1: Names and Input
22

33

4+
let hacker1 = "Alex";
5+
console.log(`The driver's
6+
name is ${hacker1}`);
7+
8+
let hacker2 = "Alexander";
9+
console.log("The navigator's name is " + hacker2);
10+
411
// Iteration 2: Conditionals
12+
if (hacker1.length > hacker2.length) {
13+
console.log(
14+
`The driver has the longest name. It has ${hacker1.length} characters.`
15+
);
16+
} else if (hacker1.length < hacker2.length) {
17+
console.log(
18+
`It seems that the navigator has the longest name, it has ${hacker2.length} characters.`
19+
);
20+
} else {
21+
console.log(
22+
`Wow, you both have equally long names, ${hacker1.length} characters!`
23+
);
24+
}
25+
26+
switch (true) {
27+
case hacker1.length > hacker2.length:
28+
console.log(
29+
`The driver has the longest name. It has ${hacker1.length} characters.`
30+
);
31+
break;
32+
case hacker1.length < hacker2.length:
33+
console.log(
34+
`It seems that the navigator has the longest name, it has ${hacker2.length} characters.`
35+
);
36+
break;
37+
default:
38+
console.log(
39+
`Wow, you both have equally long names, ${hacker1.length} characters!`
40+
);
41+
}
42+
43+
console.log("ITERATION 3")
44+
45+
// Iteration 3: Loops
46+
// 3.1 Print all the characters of the driver's name, separated by a space and in capitals i.e. "J O H N"
47+
// let driver = [];
48+
// for(let i=0; i<hacker1.length; i++){
49+
// driver.push(hacker1[i])
50+
// }
51+
console.log( hacker1.split('').join(' ').toUpperCase() )
52+
53+
54+
console.log('3.2 Print all the characters of the navigators name, in reverse order. i.e. "nhoJ"')
55+
56+
let navigatorReverse = []
57+
for(let i=hacker2.length-1; i>=0; i--){
58+
console.log(i)
59+
navigatorReverse.push(hacker2[i])
60+
}
61+
62+
console.log( navigatorReverse.join('') )
63+
64+
// console.log( hacker2.split('').reverse().join('') )
65+
66+
console.log(`3.3 Depending on the lexicographic order of the strings, print:
67+
- The driver's name goes first.
68+
- Yo, the navigator goes first definitely.
69+
- What?! You both have the same name?`)
70+
71+
let names = [hacker1, hacker2];
72+
console.log(names)
73+
74+
names.sort();
75+
console.log(names)
76+
77+
78+
// if(hacker1.length < hacker2.length){
79+
// console.log(`The ${hacker1} name goes first.`)
80+
// }
81+
// else if (hacker2.length < hacker1.length){
82+
// console.log(`Yo, the ${hacker2} goes first definitely.`)
83+
// }
84+
// else {
85+
// console.log(`What?! You both have the same name?`)
86+
// }
87+
88+
89+
if ( hacker1.localeCompare(hacker2) === -1){
90+
console.log(`The ${hacker1} name goes first.`)
91+
}
92+
else if ( hacker1.localeCompare(hacker2) === 1) {
93+
console.log(`Yo, the ${hacker2} goes first definitely.`)
94+
}
95+
else {
96+
console.log(`What?! You both have the same name?`)
97+
}
98+
99+
// hacker1.localeCompare(hacker2) === -1 ? : "true dogs" : "false cats"
100+
// // 2 + 2 === 5 ? "true dogs" : "false cats"
101+
// // "false cats"
102+
103+
104+
105+
106+
let par1 = `25 shmeckles? I-I-I-I don't even know what that- what is that? Is that a lot? There's pros and cons to every alternate timeline. Fun facts about this one – It's got giant, telepathic spiders, 11 9/11s, and the best ice cream in the multiverse! This is because you give Morty Smith bad grades, bitch! Listen, Morty, I hate to break it to you but what people call love is just a chemical reaction that compels animals to breed`
107+
108+
let par2 = `If you break the rules, try to leave or lose the game, you will die. Just like Saaaaw. Not today bitch! Flip the pickle over. Wow, so your origin is what? You fell into a vat of redundancy?`
109+
110+
let par3 = `"And"? What more youtube do you want tacked on to this? I turned myself into a pickle, and 9/11 was an inside job?" He threatened to turn me in to the government, so I made him and the government go away! I'm Mr. Crowbar, and here is my friend, who is also a crowbar! Must… continue… moving… in… ways… that… lead… to… dying… with… you.`
111+
112+
113+
114+
115+
console.log((par1 + par2 + par3).split(' ').length)
116+
117+
let par = par1 + par2 + par3 //Made it into one string
118+
119+
console.log( par.split('you').length - 1 )
120+
121+
//RegExp
122+
console.log( par.match(/you/g).length )
123+
124+
125+
126+
let phraseToCheck = "A man, a plan, a canal, Panama!"
127+
phraseToCheck = phraseToCheck.replace(/[,! ]/g,"").toLowerCase()
128+
129+
130+
let reversePhrase = phraseToCheck.split('').reverse().join('')
5131

132+
console.log(phraseToCheck)
133+
console.log(reversePhrase)
134+
console.log(phraseToCheck == reversePhrase)
6135

7-
// Iteration 3: Loops

styles.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
body{
3+
background-color:magenta;
4+
}

0 commit comments

Comments
 (0)