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


Please Help Members By Posting Answers For Below Questions

How much time it will take to learn javascript?

452


how to write frame work Architecture in QTP

1510


How to create an array in javascript?

564


What is the difference between innerhtml and append() in javascript?

663


Which built-in method returns the calling string value converted to lower case?

704






What is undefined x 1 in JavaScript?

496


What would be the result of 3+2+”7″?

752


What is the difference between remove() and removeChild()?

495


What do I need to code javascript?

462


Is javascript enabled on my computer?

452


Explain mul function in javascript?

531


What is Browser Object Model?

526


How to replace all occurrences of a string in JavaScript?

495


What is a boolean search?

474


Is JavaScript a case-sensitive language?

541