Can you write a random integers function to print integers with in a range?
Answer Posted / hrpatelsoft@gmail.com
function randomInteger(min, max) {
return Math.floor(Math.random() * (max - min + 1) ) + min;
}
randomInteger(1, 100); // returns a random integer from 1 to 100
randomInteger(1, 1000); // returns a random integer from 1 to 1000
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Why is java better than javascript?
How to have the status line update when the mouse goes over a link (the support of the status line is sporadic)?
How to add multiple functions in javascript?
What is arguments object in JavaScript?
Is javascript enabled on chrome?
How do you target a specific frame from a hyperlink in javascript?
How can a value be appended to an array?
Which built-in method returns the length of the string?
What is the use of isNaN function?
How to write a script for "select" lists using javascript
Explain promise in javascript?
What is stack queue?
Where do I write javascript code?
What is an ECMAScript?
How to find the selected radio button immediately using the 'this' variable?