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

What is webassembly good for?

535


Is javascript used for backend?

551


What is the difference between call & apply?

561


What is slug in javascript?

571


What is javascript ‘strict mode’?

571






What is spread syntax?

569


What is difference between java and javascript?

585


Why is java better than javascript?

532


Explain typecasting in javascript?

554


What is dom in javascript?

615


What are JavaScript Data Types?

650


List few advantages of using javascript?

562


Write a way by which you can do something on the close of the window ?

639


What is use strict in javascript?

573


all possible test cases for normal number field,name field date field,check box,

1049