Skip to content
Closed
Show file tree
Hide file tree
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
Binary file added .DS_Store
Binary file not shown.
39 changes: 38 additions & 1 deletion starter-code/basic-algorithms.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,44 @@
// Names and Input

var hacker1 = "Marco";

console.log("The driver's name is " + hacker1);

var hacker2 = prompt("The navigator's name is:");

console.log("The navigator'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, " + hacker1.length + " characters!!");
}

// Loops

console.log(hacker1.toUpperCase().split("").join(" "));

console.log(hacker2.split("").reverse().join(""));

var compare = hacker1.localeCompare(hacker2);

if (compare <= -1){
console.log("The driver's name goes first");
} else if (compare >= 1) {
console.log("Yo, the navigator goes first definitely");
} else console.log("What?! You both got the same name?");

// Bonus Time! - Palindrome

var tryPalindrome = prompt("Write a text, we check if it is a palindrome");
console.log("Sorry, we are working on this function");

// Bonus Time! - Lorem ipsum

// Lorem ipsum generator
var loremIpsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi sed purus ut diam varius rhoncus vitae vel augue. In bibendum augue arcu, sit amet egestas dui suscipit vel. In hac habitasse platea dictumst.";
console.log("Lorem ipsum has " + loremIpsum.length + " words.");
console.log("Lorem ipsum has " + loremIpsum.match(/et/g) .length + " latin words with -et");