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
72 changes: 69 additions & 3 deletions starter-code/basic-algorithms.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,73 @@
// Names and Input
//1.Create a driver variable
var hacker1 = "Lexy";

//2. Print driver
console.log("The driver name is " + hacker1);

//3. Create navigator's name
var hacker2 = window.prompt("What is your name?");

//4. Print navigator
console.log("The navigator's name is " + hacker2);

//5. If hacker1 or hacker2 has the longest name
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");
}

//6.Print driver characters separate by a space and in capitals
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.

Good job on this one!

var temp = ""; //
for(var i = 0; i < hacker1.length; i++){
if(i === hacker1.length-1){
temp += (hacker1[i].toUpperCase());
}
else {
temp += (hacker1[i].toUpperCase()) + " ";
}
}
console.log(temp);

//7. Print navgator's name in reverse
temp = "";
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.

Great!

for(i = hacker2.length-1; i >= 0; i--){
temp += hacker2[i];
}
console.log(temp);

//8.Determining the lexicographic order
if(hacker1.charCodeAt(0) < hacker2.charCodeAt(0)){
console.log("Yes, it is smaller");
}

























//Conditionals


// Lorem ipsum generator