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.
40 changes: 37 additions & 3 deletions starter-code/basic-algorithms.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,41 @@
// Names and Input
let hacker1 = "Doug";
let hacker2 = prompt("Who is the driver?")
let driverLetters = "";
let navLetter = "";
console.log("The drivers name is ", hacker1);
console.log("The navigator 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 + hacker2.length + " characters!!")
}

// Lorem ipsum generator


for(var i = 0; i < hacker1.length; i++) {
driverLetters+= hacker1.toUpperCase()[i];
driverLetters+= " ";
}

console.log(driverLetters);

for(var i = hacker2.length -1; i >= 0; i--) {
navLetter+= hacker2[i];

}
console.log(navLetter);



var myObject = [hacker1, hacker2];

for(var i = 0; i < myObject.length; i++) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can try applying .localeCompare() in order to set them in alphabetical order. Let me know if you need help.

myObject.sort()[i];
}

console.log(myObject);