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
42 changes: 42 additions & 0 deletions claudiaheleyni.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
console.log("I'm Ready!");

var hacker1 = "Claudia"
console.log ("The drivers name is " + hacker1);

var hacker2 = "Eleyni"
console.log ("The navigators name is " + hacker2);

if (hacker1.length > hacker2.length) {
console.log ("The driver has 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 if (hacker1.length = hacker2.length) {
console.log ("wow, you both got equally long names " + hacker2.length + " characters!")
}

var driver = " "
for (var i = 0; i < hacker1.length; i++) {
driver += hacker1.toUpperCase()[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.

This works. The other way would be using JS methods:

for (var i = 0; i < 1; i++) {
  console.log(
    hacker1
      .split("")
      .join(" ")
      .toUpperCase()
  );
}

console.log(driver)

function reverse(str) {
return str.split('').reverse().join('');

}
reverse(hacker2);

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!



var names = [hacker1, hacker2];
names.sort();
console.log(names);


if (names.indexOf(hacker1)===0){
console.log("The drivers name goes first")
} else if (names.indexOf(hacker2)===0){
console.log("Yo, tha navigator goes first definitely");
} else {
console.log("what?! you both got the same name?");
}

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.

Try this way:

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

Google what .localeCompare() does and ask us if you have any questions.