-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
47 lines (37 loc) · 1.09 KB
/
index.js
File metadata and controls
47 lines (37 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Iteration 1: Names and Input
let driverName=`Caro`;
console.log(`The driver's name is ${driverName}`)
let navigatorName=`Peter Parker`;
console.log(`The navigator's name is ${navigatorName}`)
// Iteration 2: Conditionals
if (driverName >= navigatorName){
console.log(`The driver has longest name,
it has ${driverName.length}`);
}
else if (driverName <= navigatorName){
console.log (`
It seems that the navigator
has the longest name
it has ${navigatorName.length} characters.`);
}
else if (driverName === navigatorName){
console.log(`
Wow, you both have equally long names, ${driverName.length}
`);
}
// Iteration 3: Loops
console.log(driverName.toUpperCase());
console.log(driverName.reverse);
function reverse(str) {
let splitString = str.split("");
let reverseArray = splitString.reverse();
let joinArray = reverseArray.join("");
return joinArray;
}
reverse(driverName);
let frases=[
`The driver's name goes first`,
`Yo, the navigator goes first definitely`,
`What?! You both have the same name?`,
]
frases.sort();