Skip to content

Commit 8fe9fb1

Browse files
committed
lab terminado
1 parent f3a2616 commit 8fe9fb1

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

index.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,61 @@
1+
2+
3+
4+
15
// Iteration 1: Names and Input
26

37

8+
const hacker1 = 'John';
9+
console.log(`The driver is ${hacker1}`);
10+
11+
const hacker2 = 'Navigator';
12+
console.log(`The navigator´s name is ${hacker2}`);
13+
14+
415
// Iteration 2: Conditionals
516

17+
if (hacker1.length > hacker2.length) {
18+
console.log(`The driver has the longest name, it has ${hacker1.length} characters`);
19+
} else if (hacker1.length < hacker2.length) {
20+
console.log(`It seems that the navigator has the longest name, it has ${hacker2.length} characters`);
21+
} else {
22+
console.log(`"Wow, you both have equally long names, ${hacker1.length} characters!"`)
23+
}
24+
625

726
// Iteration 3: Loops
27+
28+
29+
let nombreEnMayusculas = "" // <- variable helper
30+
31+
for (let i = 0; i < hacker1.length; i++) {
32+
nombreEnMayusculas = nombreEnMayusculas + hacker1[i].toUpperCase() + " "
33+
}
34+
35+
console.log(nombreEnMayusculas)
36+
37+
let nombreInvertido = "" // <- variable helper
38+
39+
for (let i = hacker1.length - 1; i >= 0; i--) {
40+
nombreInvertido = nombreInvertido + hacker1[i]
41+
}
42+
43+
console.log(nombreInvertido)
44+
45+
46+
///////////////////////////////////////////////////////////
47+
48+
const names = [hacker1, hacker2]
49+
50+
for (i=0; i < names.length; i++) {
51+
if (names[0].length > names[1].length) {
52+
console.log("The driver's name goest first.");
53+
} else if (names[0].length < names[1].length) {
54+
console.log("Yo, the navigator goes first, definitely.");
55+
} else {
56+
console.log("What?! You both have the same name?");
57+
}
58+
}
59+
60+
61+

0 commit comments

Comments
 (0)