Numero aleatorio por rango


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. function aleatorio(inferior,superior){
  2. numPosibilidades = superior - inferior
  3. aleat = Math.random() * numPosibilidades
  4. aleat = Math.round(aleat)
  5. return parseInt(inferior) + aleat
  6. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.