Advertisement
fbinnzhivko

Untitled

Sep 29th, 2016
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function vol(input) {
  2.  
  3.     let number = input.map(Number); //object
  4.  
  5.     for (i = 0; i < input.length; i += 3) {
  6.         let x = input[i];
  7.         let y = input[i + 1];
  8.         let z = input[i + 2];
  9.  
  10.         if (inVolume(x, y, z)) {
  11.             console.log('inside');
  12.         }
  13.         else {
  14.             console.log('outside');
  15.         }
  16.         function inVolume(x, y, z) {
  17.             let x1 = 10, x2 = 50;
  18.             let y1 = 10, y2 = 50;
  19.             let z1 = 10, z2 = 50;
  20.  
  21.             if (x >= x1 && x <= x2) {
  22.                 if (y >= y1 && y <= y2) {
  23.                     if (z >= z1 && z <= z2) {
  24.                         return true;
  25.                     }
  26.                 }
  27.             }
  28.             return false;
  29.         }
  30.  
  31.     }
  32. }
  33. // vol([8,20,22]);
  34. // vol([13.1, 50, 31.5, 50, 80, 50, -5, 18, 43]);
  35. vol([ 50, 80, 50]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement