Skip to content

MIA - KatAlderman - Lab-Javascript-Basic-Algorithms - #95

Closed
katalderman wants to merge 1 commit into
ironhack-labs:masterfrom
katalderman:master
Closed

MIA - KatAlderman - Lab-Javascript-Basic-Algorithms#95
katalderman wants to merge 1 commit into
ironhack-labs:masterfrom
katalderman:master

Conversation

@katalderman

Copy link
Copy Markdown

Submitting my work for review!


for (var x=0;x <= hacker1.length; x++) {
console.log(hacker1.charAt(x).toUpperCase(x));
}

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 approach! The other way could be:

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

return joinArray;
}
console.log(reverseString(hacker1));

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.

Again good way of thinking. The same but maybe a bit shorter way would be:

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


}

else if (hacker1 > 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.

The logic is there but the syntax is not. We could use something like this:

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);

Try googling .localeCompare() to see how this method works.

@sandrabosk

Copy link
Copy Markdown
Contributor

Good job so far. Try finishing the bonus part if you have time. Thank you for submitting.

@sandrabosk sandrabosk closed this Apr 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants