Guest User

Untitled

a guest
May 26th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. // console.log("I'm Ready!");
  2.  
  3. // var hacker1 = "Jack";
  4.  
  5. // // console.log("The driver's name is " + hacker1);
  6.  
  7. // var hacker2 = prompt("What is the navigator's name?");
  8. // console.log("The navigator's name is " + hacker2);
  9.  
  10. // // if (hacker1.length > hacker2.length) {
  11. // // console.log("The Driver has the longest name, it has " + hacker1.length + " characters");
  12. // // }
  13.  
  14. // // else if (hacker1.length < hacker2.length) {
  15. // // console.log("Yo, navigator got the longest name, it has " + hacker2.length + " characters");
  16. // // }
  17.  
  18. // // else if (hacker1.length === hacker2.length) {
  19. // // console.log("wow, you both got equally long names, " + hacker2.length + " characters!!");
  20. // // }
  21. // var string = "";
  22. // for (var i = 0; i < hacker1.length; i++) {
  23. // string += hacker1.toUpperCase()[i] + " ";
  24. // }
  25.  
  26. // console.log(string);
  27.  
  28. // var string2 = ''
  29. // for (var j = 0; j < hacker2.length; j++) {
  30. // string2 += hacker2[hacker2.length - j - 1];
  31. // }
  32.  
  33. // console.log(string2)
  34.  
  35. // if (hacker1 < hacker2) {
  36. // console.log('The driver\'s name goes first')
  37. // }
  38. // else if (hacker2 < hacker1) {
  39. // console.log('Yo, the navigator goes first definitely')
  40. // }
  41. // else if (hacker1 === hacker2) {
  42. // console.log('What?! You both got the same name?')
  43. // }
  44.  
  45. var palindrome = prompt("Down here check if that is a palindrome.");
  46.  
  47. var palindrome = palindrome.toUpperCase()
  48. var palindromeBackwards = ''
  49. var palindromeClean = ''
  50.  
  51. for (var k = 0; k < palindrome.length; k++) {
  52. if (palindrome[palindrome.length - k - 1] <= 'Z' && palindrome[palindrome.length - k - 1] >= 'A') {
  53. palindromeBackwards += palindrome[palindrome.length - k - 1];
  54. }
  55. if (palindrome[k] >= 'A' && palindrome[k] <= 'Z')
  56. palindromeClean += palindrome[k]
  57. }
  58. console.log(palindromeClean + " " + palindromeBackwards)
  59.  
  60. if (palindromeBackwards.toUpperCase() === palindromeClean) {
  61. console.log("It is!");
  62. }
  63.  
  64. else {
  65. console.log("It isn't.");
  66. }
Add Comment
Please, Sign In to add comment