Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function main(lines) {
- lines=lines.map(Number);
- let island=function(x,y) {
- switch(true){
- case (x>=5&&x<=7&&y>=3&&y<=6):
- console.log('Samoa');
- break;
- case (x>=8&&x<=9&&y>=0&&y<=1):
- console.log('Tokelau');
- break;
- case (x>=1&&x<=3&&y>=1&&y<=3):
- console.log('Tuvalu');
- break;
- case (x>=0&&x<=2&&y>=6&&y<=8):
- console.log('Tonga');
- break;
- case (x>=4&&x<=9&&y>=7&&y<=8):
- console.log('Cook');
- break;
- default:
- console.log('On the bottom of the ocean');
- break;
- }
- };
- for (let i = 0; i < lines.length; i+=2) {
- let x=lines[i];
- let y=lines[i+1];
- island(x,y);
- }
- }
- main(['4', '2', '1.5', '6.5', '1', '3']);
- // main(['6','4']);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement