Skip to content

Instantly share code, notes, and snippets.

@anaamilo
Last active June 12, 2017 15:57
Show Gist options
  • Save anaamilo/0f160e61c6573a091c7b9f88c5e56192 to your computer and use it in GitHub Desktop.
Save anaamilo/0f160e61c6573a091c7b9f88c5e56192 to your computer and use it in GitHub Desktop.
JS | Basic Algorithms
console.log("I'm Ready!");
var hacker1 = "Ana";
console.log("The driver's name is " + hacker1);
var hacker2 = prompt("What's the navigator's name?");
console.log("The navigator's name is " + hacker2);
if(hacker1.length > hacker2.length){
console.log("The Driver has the longest name, it has " + hacker1.length + " characters");
}else if(hacker2.length > hacker1.length){
console.log("Yo, navigator got the longest name, it has " + hacker2.length + " characters");
}else{
console.log("Wow, you both got equally long names, " + hacker1.length + " characters!!");
}
var driverName = "";
for(var i = 0; i < hacker1.length; i++){
var letter = hacker1[i].toUpperCase();
driverName += (letter + " ");
}
console.log(driverName);
var navName = "";
for(var i = (hacker2.length-1); i >= 0; i--){
var inverse = hacker2[i];
navName += (inverse);
}
console.log(navName);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment