Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
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
45 changes: 44 additions & 1 deletion 45 starter-code/basic-algorithms.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,50 @@
// Names and Input
var hacker1 = "Chu";

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

//Conditionals
var hacker2 = "Ariel";

console.log("Navigator's name is " + hacker2);

function nameLength() {
if (hacker1.length > hacker2.length){
console.log("The driver's got 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, " + hacker2.length + " characters");
}
}

nameLength();

var horizontalName = "";
for (var i = 0; i <= hacker1.length - 1; i++){

horizontalName += hacker1[i] + " ";

}
console.log(horizontalName.toUpperCase() + " ");
var horizontalName2 = "";

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

//Conditionals

var palindrome = prompt ("Type any word");
palindrome = palindrome.replace(/\s/g,"");

if (palindrome === palindrome.split("").reverse().join("")) {

Choose a reason for hiding this comment

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

Great use of the split(), reverse(), and join() functions here.

console.log("This is a Palindrome");
}
else {
("This is not a Palindrome");
}

// Lorem ipsum generator
Morty Proxy This is a proxified and sanitized view of the page, visit original site.