forked from ironhackbcn/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
40 lines (23 loc) · 983 Bytes
/
basic-algorithms.js
File metadata and controls
40 lines (23 loc) · 983 Bytes
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
var hacker1= "Damian ";
console.log ("The driver's name is" + hacker1 )
var hacker2 = prompt("What's your navigation's name?");
console.log ("Is: " + hacker2 );
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, "+ hacker2.length + " characters ")
} else {
console.log ("wow, you both got equally long names, "+ hacker2.length + " characters ")
}
console.log((hacker1.toUpperCase()).split(''));
console.log(hacker2.split('').reverse().join(''));
//lexicographic order
var palindrome= prompt("What do you want to chesk if it is a polindrome?")
for (var i=0; i< palindrome.length; i++) {
if ( palindrome[i] === palindrome[ (palindrome.length) - i ] ) {
console.log ("Yeah it is a polindrome")
} else {
console.log ("Sorry it's not a polidrome ")
}
}
// Lorem ipsum generator