1.

Math.random() returns _______________(a) random number between 0 and 1(b) random number between 1 and 10(c) random number between 1 and 100(d) random number between 0 and 10I had been asked this question in an international level competition.This intriguing question comes from Essential JavaScript and jQuery in division HTML Tables, Javascript & Jquery Basics of HTML

Answer»

Right option is (a) random number between 0 and 1

To explain I WOULD say: Math.random() generate any random number between 0 and 1. If we use Math.random() with Math.floor() it returns any random integer. E.g. Math.floor(Math.random * 1000); It will generate any random number between 0 and 999. For the SAKE of CONVENIENCE we can also DEFINE a random function.



Discussion

No Comment Found

Related InterviewSolutions