SHARE
TWEET

Untitled

a guest Dec 8th, 2019 177 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const cardeal = document.getElementById('cardeal')
  2.  
  3. const regrasDePosicoes = [
  4.   { min: 1,   max: 21,  cardeal: 'N'  },
  5.   { min: 22,  max: 66,  cardeal: 'NE' },
  6.   { min: 67,  max: 111, cardeal: 'E'  },
  7.   { min: 112, max: 156, cardeal: 'SE' },
  8.   { min: 157, max: 201, cardeal: 'S'  },
  9.   { min: 202, max: 246, cardeal: 'SO' },
  10.   { min: 247, max: 291, cardeal: 'O'  },
  11.   { min: 292, max: 336, cardeal: 'NO' },
  12.   { min: 337, max: 360, cardeal: 'N'  }
  13. ]
  14.  
  15. const verificarPosicao = (_posicao) => {
  16.   if (!_posicao) return
  17.  
  18.   for (let index in regrasDePosicoes) {
  19.     const regra = regrasDePosicoes[index]
  20.    
  21.     if (_posicao >= regra.min && _posicao <= regra.max) return regra.cardeal
  22.   }
  23. }
  24.  
  25. // DOM
  26. cardeal.innerText = verificarPosicao(67)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top