/ Published in: JavaScript
Simple function to return a decimal value between the minValue and the maxValue.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// Random float between function randomFloatBetween(minValue,maxValue,precision){ if(typeof(precision) == 'undefined'){ precision = 2; } return parseFloat(Math.min(minValue + (Math.random() * (maxValue - minValue)),maxValue).toFixed(precision)); }