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
Which type of variable among global and local, takes precedence over other if names are same?
How do you create array in javascript?
How does javascript work?
What do “1”+2+4 evaluate to?
What is an Event Bubbling in Javascript?
Why are callbacks used?
What is prototype in javascript and how do you use it?
Create an array in javascript with a list of 4 colors, assign that array to the variable, ‘colors’.
How to get height and width of different browser in Javascript?
How to encode and decode a url in javascript?
What is the difference between registerclientscriptblock and registerstartupscript?
Why is javascript used for web pages?
Which is best for front end?
How do browsers work?
What is the use of anonymous function in javascript?