Guest User

Untitled

a guest
Jul 11th, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. <script>
  2.  
  3. String.prototype.reverse=function(){return this.split("").reverse().join("");}
  4.  
  5. String.prototype.replaceAt=function(index, char) {
  6. return this.substr(0, index) + char + this.substr(index+char.length);
  7. }
  8.  
  9. function include(arr,obj) {
  10. return arr.indexOf(obj);
  11. }
  12.  
  13. var alphabet =
  14.  
  15. ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w'
  16.  
  17. ,'x','y','z'];
  18.  
  19. var city_list = ["New York"];
  20.  
  21. var list = [
  22. "Elephant",
  23. "Alligator",
  24. "Kestrel",
  25. "Condor",
  26. "Arctic Fox",
  27. "Bald Eagle",
  28. "Black Swan",
  29. "Duck",
  30. "Burrowing Owl",
  31. "Sea Lion",
  32. "Chinchilla",
  33. "Collared Peccary",
  34. "Rabbit",
  35. "Snake",
  36. "Hedgehog",
  37. "Owl",
  38. "Bear",
  39. "Leopard",
  40. "Shark",
  41. "Panda",
  42. "Lynx",
  43. "Llama",
  44. "Marine Toad",
  45. "Mouflon",
  46. "Musk Ox",
  47. "Arrow Frogs",
  48. "Porcupine",
  49. "Tortoise",
  50. "Red Panda",
  51. "Lemur",
  52. "Hawk",
  53. "Rhea",
  54. "Reindeer",
  55. "Siberian Tiger",
  56. "Snow Leopard",
  57. "Snowy Owl",
  58. "Whites Tree Frog",
  59. "Wild Boar",
  60. "Invertebrates",
  61. "Centipedes",
  62. "Crustaceans",
  63. "Hermit Crabs",
  64. "Wood Louse",
  65. "Bullet Ant",
  66. "Carpenter Bee",
  67. "Honey Pot Ant",
  68. "Honeybee",
  69. "Snails",
  70. "Spiders",
  71. "Scorpions",
  72. "Fish",
  73. "Zebra",
  74. "Tiger",
  75. "Crocodiles",
  76. "Lizards",
  77. "Snakes",
  78. "King Cobra",
  79. "Turtles",
  80. "Birds",
  81. "Penguins",
  82. "Bats",
  83. "Cheetah",
  84. "Mongoose",
  85. "Jaguar",
  86. "Kinkajou",
  87. "Lion",
  88. "Otter",
  89. "Polar Bear",
  90. "Puma",
  91. "Red Panda",
  92. "Sand Cat",
  93. "Slender",
  94. "Hyena",
  95. "Rhinoceros",
  96. "Gazelle",
  97. "Goat",
  98. "Hippopotamus",
  99. "Okapi",
  100. "Pig",
  101. "Warthog",
  102. "Hyraxes",
  103. "Lemurs",
  104. "Monkey",
  105. "Ape",
  106. "Chimpanzee",
  107. "Gorilla",
  108. "Kangaroo",
  109. "Opossum",
  110. "Giraffe",
  111. "Killer Whale",
  112. "Horse",
  113. "Wolf",
  114. "Mole",
  115. "Dingo",
  116. "Deer",
  117. "Emu",
  118. "Crocodile",
  119. "Bobcat",
  120. "Lion",
  121. "Squirrel"
  122. ];
  123.  
  124. for(var i=0;i<city_list.length;i++) {
  125. city_list[i] = city_list[i].toLowerCase();
  126. }
  127.  
  128. for(var i=0;i<list.length;i++) {
  129. var result, word = list[i].toLowerCase();
  130. var fifth = word.substring(4,5);
  131.  
  132. // search 5th char index
  133. var fifth_alp = include(alphabet, fifth);
  134.  
  135. // change 5th char to next
  136. result = word.replaceAt(4, alphabet[fifth_alp + 1]);
  137.  
  138. // remove 2nd char
  139. result = result.replaceAt(1, "");
  140.  
  141. // reverse word
  142. result = result.reverse();
  143.  
  144. // print
  145. document.write(list[i] + " => " + result);
  146.  
  147. // check match city
  148. if(include(city_list, result) != -1) {
  149. document.write(" Found !!");
  150. }
  151.  
  152. document.write("<br />");
  153.  
  154. }
  155.  
  156.  
  157. </script>
Add Comment
Please, Sign In to add comment