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
How to convert json object to string?
How to get the primitive value of a string in Javascript?
What is memory leak in javascript?
How are object properties assigned?
Why is it called javascript?
What is the difference between childNode and children?
Is javascript event driven?
What are the five data types?
Explain few difference between null, undefined or undeclared javascript variable?
Is javascript case sensitive?
What is a closure and how do you use it?
What is a global variable in programming?
What is a boolean in javascript?
What are the main uses of javascript?
What is javascript in simple terms?