forked from ironhack-labs/lab-javascript-basic-algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic-algorithms.js
More file actions
55 lines (48 loc) · 1.49 KB
/
basic-algorithms.js
File metadata and controls
55 lines (48 loc) · 1.49 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
47
48
49
50
51
52
53
54
// Names and Input
var hacker1 = "Guillaume";
console.log("The driver's name is " + hacker1);
var hacker2;
var hacker2 = prompt ("What's your navigator name");
console.log("The navitor's name is " + hacker2);
//Conditionals
if (hacker1.length > hacker2.length){
console.log("The Driver has the longest name, it has " + hacker1.length + " characters.")
}
else if (hacker1.length < hacker2.length) {
console.log("Yo, navigator got the longest name, it has " + hacker2.length + " characters.")
}
else {
console.log("wow, you both got equally long names, XX characters!!")
}
var hacker1 = hacker1.toUpperCase();
console.log(hacker1);
var hacker1 = hacker1.split('').join(" ");
console.log(hacker1);
function reverseString(hacker1) {
var reverseStringHacker1 ="";
for (var i = hacker1.length - 1; i >= 0; i--) {
reverseStringHacker1 = reverseStringHacker1 + hacker1[i];
}
return reverseStringHacker1;
}
console.log(reverseString(hacker1));
var reverseStringHacker1 = reverseString(hacker1);
console.log(reverseStringHacker1);
var tableau=[hacker1,hacker2];
console.log(tableau);
tableau.sort();
console.log(tableau);
if (tableau[0] === hacker1){
console.log("The driver's Guillaume goes first");
}
else if (tableau[1] === hacker2){
console.log("The driver 2 goes first for sure")
}
else if (tableau[1] === tableau[2]){
console.log("You have the same name")
}
else {
console.log("la fin des haricots si tu vois ça")
}
console.log("testgitpull")
// Lorem ipsum generator