article

 Math Object

[WHAT]

  1. [] the Math object is used to perform a number of mathematical functions.

[WHY]

  1. [] to perform standard math operations on numbers without having to write 

[WHERE]

  1. [] you need to perform 'standard' mathematical functions on a given number, such as sqrt, log, sin,

[WHEN]

  1. [] 

[EXAMPLE]

  1. [] generating a random number
var randomNum = Math.random() // returns a value between 0 and 1
  1. [] generating a random number between 1 and 100
getRandomBetween(min,max){
   return Math.random() * (max - min) + min;
}
console.log(getRandomNumberBetween(1,100); // this returns a float, so will get 51.78
  1. [] would you then use Math.round() or Math.floor to return an integer value ?
round would return 52, floor would return 51
  1. [] get the largest number in a given set of numbers
var largest = Math.max(17,9,23,44);

[HOW-TO]

  1. []

[REFERENCE]

  1. [] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math 
Details Photos Edit more

Details

ID: 2707

NAME: Math

DESCRIPTION: Math - an overview of the native JavaScript language object Math

AUTHOR: article.author/s

EDITOR: article.editor/s

PUBLISHER: article.publisher/s

STATUS: Write

PRIORITY: -5

OWNER ID: 75

Content Photos Edit more

photos

page_photo

actions

Email Email-Owner SMS and