Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 31 additions & 4 deletions starter-code/basic-algorithms.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,34 @@
// Names and Input


var hacker1 = "Miguel";
console.log("The driver's name is " + hacker1);
var hacker2 = prompt("Enter name");
console.log("The navigator's name is " + hacker2);
//Conditionals


if (hacker1 > hacker2){
console.log("The driver has the longes name, it has " + hacker1.length + " characters");
} else if(hacker1 < hacker2){
console.log("the navigator got the longest name, it has " + hacker2.length + " characters");
} else {
console.log("Wow, you both got equally long names, " + hacker1.length + " characters!!");
}
console.log(hacker1.toUpperCase().split("").join(" "));
console.log(hacker2.split("").reverse().join(""));
if(hacker1<hacker2){
console.log("The drivers name goes first.");
} else if(hacker1 > hacker2){
console.log("Yo, the navigator goes first definitely.");
} else{
console.log("What?! You both got the same name?");
}
var usrString = prompt("inset text");
if(usrString == usrString.split("").reverse().join("")){
console.log("It's a palindrome!!");
} else{
console.log("This is not a palindrome");
}
// Lorem ipsum generator
var loremString = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam lacinia dignissim dictum. Quisque varius iaculis suscipit."
var wordSplit = loremString.split(" ").length;
console.log(wordSplit);
var matches = loremString.match(/et/gi).length;
console.log(matches);