Skip to content

Paris - Alexandre - Bastien#299

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

Paris - Alexandre - Bastien#299
alexjoly13 wants to merge 1 commit into
ironhack-labs:masterfrom
alexjoly13:master

Conversation

@alexjoly13
Copy link
Copy Markdown

var alphabet = "abcdefghijklmnopqrstuvwxyz";
var candidate = prompt("Testez la palindromie du mot");
for (i=0 ; i <= candidate.length-1; i++) {
if (!alphabet.includes(candidate[i])) {candidate=candidate.substr(0,i-1)+candidate.substr(i+1,candidate.length-1);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I'm not entirely sure what you are trying to do here. There is an easier way to check to see if it's a palindrome


if (nameNormal.replace(" " ,"") === nameReversed.replace(" ", "")) {
  console.log("It's a palindrome !!");
} else {
  console.log("It's not a palindrome...");
};

var hacker2 = prompt("Enter the navigator's name"); console.log("The navigator's name is " + hacker2);
if (hacker1.length === hacker2.length) {
console.log("wow, you both got equally long names, " + hacker1.length + " characters!!") }
else if (hacker1.length <= hacker2.length) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

here you don't want to be checking if it's greater than or equal to- you only want to check to see if it is greater than since you're checking for the longest name

@ta-web-paris
Copy link
Copy Markdown

What you've done is good! You seem to understand how loops work which will be important throughout the course 💪

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