Advertisement
Guest User

Treasure Locator

a guest
Sep 30th, 2016
474
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function treasureLocator(input){
  2.     for (let i = 0; i < input.length; i+=2) {
  3.         let x = Number(input[i]);
  4.         let y = Number(input[i+1]);
  5.         treasureFinder(x,y);
  6.     }
  7.     function treasureFinder(pointX,pointY){
  8.         if(pointX >=8 && pointX <= 9 && pointY >= 0 && pointY <= 1){
  9.             console.log('Tokelau');
  10.         }
  11.         else if (pointX >= 1 && pointX <= 3 && pointY >= 1 && pointY <= 3){
  12.             console.log('Tuvalu');
  13.         }
  14.         else if (pointX >= 5 && pointX <= 7 && pointY >= 3 && pointY <= 6){
  15.             console.log('Samoa');
  16.         }
  17.         else if (pointX >= 0 && pointX <= 2 && pointY >= 6 && pointY <= 8){
  18.             console.log('Tonga');
  19.         }
  20.         else if (pointX >= 4 && pointX <= 9 && pointY >= 7 && pointY <= 8){
  21.             console.log('Cook');
  22.         }
  23.         else if(pointX >= 0 && pointX <= 9 && pointY >= 0 && pointY <= 9){
  24.             console.log('On the bottom of the ocean');
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement