Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- String.prototype.reverse=function(){return this.split("").reverse().join("");}
- String.prototype.replaceAt=function(index, char) {
- return this.substr(0, index) + char + this.substr(index+char.length);
- }
- function include(arr,obj) {
- return arr.indexOf(obj);
- }
- var alphabet =
- ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w'
- ,'x','y','z'];
- var city_list = ["New York"];
- var list = [
- "Elephant",
- "Alligator",
- "Kestrel",
- "Condor",
- "Arctic Fox",
- "Bald Eagle",
- "Black Swan",
- "Duck",
- "Burrowing Owl",
- "Sea Lion",
- "Chinchilla",
- "Collared Peccary",
- "Rabbit",
- "Snake",
- "Hedgehog",
- "Owl",
- "Bear",
- "Leopard",
- "Shark",
- "Panda",
- "Lynx",
- "Llama",
- "Marine Toad",
- "Mouflon",
- "Musk Ox",
- "Arrow Frogs",
- "Porcupine",
- "Tortoise",
- "Red Panda",
- "Lemur",
- "Hawk",
- "Rhea",
- "Reindeer",
- "Siberian Tiger",
- "Snow Leopard",
- "Snowy Owl",
- "Whites Tree Frog",
- "Wild Boar",
- "Invertebrates",
- "Centipedes",
- "Crustaceans",
- "Hermit Crabs",
- "Wood Louse",
- "Bullet Ant",
- "Carpenter Bee",
- "Honey Pot Ant",
- "Honeybee",
- "Snails",
- "Spiders",
- "Scorpions",
- "Fish",
- "Zebra",
- "Tiger",
- "Crocodiles",
- "Lizards",
- "Snakes",
- "King Cobra",
- "Turtles",
- "Birds",
- "Penguins",
- "Bats",
- "Cheetah",
- "Mongoose",
- "Jaguar",
- "Kinkajou",
- "Lion",
- "Otter",
- "Polar Bear",
- "Puma",
- "Red Panda",
- "Sand Cat",
- "Slender",
- "Hyena",
- "Rhinoceros",
- "Gazelle",
- "Goat",
- "Hippopotamus",
- "Okapi",
- "Pig",
- "Warthog",
- "Hyraxes",
- "Lemurs",
- "Monkey",
- "Ape",
- "Chimpanzee",
- "Gorilla",
- "Kangaroo",
- "Opossum",
- "Giraffe",
- "Killer Whale",
- "Horse",
- "Wolf",
- "Mole",
- "Dingo",
- "Deer",
- "Emu",
- "Crocodile",
- "Bobcat",
- "Lion",
- "Squirrel"
- ];
- for(var i=0;i<city_list.length;i++) {
- city_list[i] = city_list[i].toLowerCase();
- }
- for(var i=0;i<list.length;i++) {
- var result, word = list[i].toLowerCase();
- var fifth = word.substring(4,5);
- // search 5th char index
- var fifth_alp = include(alphabet, fifth);
- // change 5th char to next
- result = word.replaceAt(4, alphabet[fifth_alp + 1]);
- // remove 2nd char
- result = result.replaceAt(1, "");
- // reverse word
- result = result.reverse();
- // print
- document.write(list[i] + " => " + result);
- // check match city
- if(include(city_list, result) != -1) {
- document.write(" Found !!");
- }
- document.write("<br />");
- }
- </script>
Add Comment
Please, Sign In to add comment