diff --git a/starter-code/basic-algorithms.js b/starter-code/basic-algorithms.js index 82f20d8ba..c8cfa2c0c 100644 --- a/starter-code/basic-algorithms.js +++ b/starter-code/basic-algorithms.js @@ -1,6 +1,124 @@ -// Names and Input +//Names and Input +//from 1 to 4 +var hacker1 = prompt("which is the driver's name?"); +var hacker2 = prompt("which is the navigator's name?"); +console.log("The driver's name is " + hacker1); +console.log("The navigator's name is " + hacker2); +var longitud; +var greater; + +//Conditionals +//5 Which names is larger +if(hacker1.length>hacker2.length) +{ + longitud=hacker2.length; + greater = hacker2; + console.log("The Driver has the longest name, it has "+ hacker1.length +" characters"); +} +else if(hacker1.length=0;i--) +{ + invname += hacker2[i]; + +} + +console.log(invname); + + +//8 Compare Names order +for (var i=0;i0) + { + greater = hacker2; + + break; + } +} + + + +switch(greater) +{ + case hacker1: + console.log("The driver's name goes first"); + break; + case hacker2: + console.log("Yo, the navigator goes first definitely"); + break; + default: + console.log("What?! You both got the same name?"); + break; + +} + + +//Bonus Time +//9-Palindrome +var paraula = prompt("Enter phrase"); +var temp =""; + +for(var i=0; i