Page 253 - Web_Application_v2.0_C12_Fb
P. 253

7.  Exiting from the car’s management recording system

                    For this perform the following steps:
                    i.  Click on the Exit link. A message appears that shows exiting the program good bye!
                    ii.  Click on the OK button.





















                   2.13 MATH METHOD

                 In JavaScript, the Math object is a built-in object that provides a set of mathematical functions and constants.
                 It is not a constructor, meaning you cannot create instances of Math. Instead, it is a static object that allows
                 access to various mathematical operations.
                 Some of the Math methods are as follows:


                        Method Name                 Description          Example

                    round()                Rounds  a  number  to  the  document.write(Math.round(3.68));
                                           nearest  integer.  The round()   document.write(“,” +Math.round

                                           method rounds a number to  (5.30));
                                           the nearest integer, rounding
                                                                         document.write(“,”+Math.round
                                           up  for  decimals  ≥  0.5  and
                                                                         (-8.78));
                                           down for decimals < 0.5.
                                                                         Output:
                                                                         4,5,-9
                    random()               Returns  an  arbitrary  value  document.write(Math.random());
                                           between  0  (inclusive)  and  1
                                                                         Output:
                                           (exclusive)
                                                                         0.5492547873757196

                    max()                  Returns the largest number    document.write(Math.max(-15,
                                                                         -20));

                                                                         document.write(“<br>”+Math.
                                                                         max(150, 130, 120, 138));
                                                                         Output:
                                                                         -15
                                                                         150



                                                                                                  JavaScript Part 2  251
   248   249   250   251   252   253   254   255   256   257   258