Can you write a random integers function to print integers with in a range?



Can you write a random integers function to print integers with in a range?..

Answer / 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

More JavaScript Interview Questions

What e means?

0 Answers  


Give an example of closure?

0 Answers  


How many functions are there in javascript?

0 Answers  


Difference between '=', '==' and '===' operators?

0 Answers  


What are escape characters in javascript?

0 Answers  






Which parameter of load ()' s callback function has the data?

1 Answers  


Why javascript is fast?

0 Answers  


What is difference between javascript and jscript?

0 Answers  


What is difference between ajax and javascript?

0 Answers  


What is argument objects in javascript?

0 Answers  


Write a program in Java to display the IP address of the local and remote machine.

0 Answers   Annamalai University,


What is the difference between JavaScript and jscript?

0 Answers  


Categories