Skip to content

Commit 3c64759

Browse files
committed
finished lab
1 parent 4d8b66f commit 3c64759

File tree

3 files changed

+119
-2
lines changed

3 files changed

+119
-2
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: 96 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
// Iteration 1: Names and Input
2-
let hacker1 = "Stefan";
2+
3+
4+
let hacker1 = "Alex";
35
console.log(`The driver's
46
name is ${hacker1}`);
57

6-
let hacker2 = "Juan";
8+
let hacker2 = "Alexander";
79
console.log("The navigator's name is " + hacker2);
810

911
// Iteration 2: Conditionals
@@ -38,4 +40,96 @@ switch (true) {
3840
);
3941
}
4042

43+
console.log("ITERATION 3")
44+
4145
// 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('')
131+
132+
console.log(phraseToCheck)
133+
console.log(reversePhrase)
134+
console.log(phraseToCheck == reversePhrase)
135+

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)