Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript math methods

abs(x)	Returns the absolute value of x
acos(x)	Returns the arccosine of x, in radians
acosh(x)	Returns the hyperbolic arccosine of x
asin(x)	Returns the arcsine of x, in radians
asinh(x)	Returns the hyperbolic arcsine of x
atan(x)	Returns the arctangent of x as a numeric value between -PI/2 and PI/2 radians
atan2(y, x)	Returns the arctangent of the quotient of its arguments
atanh(x)	Returns the hyperbolic arctangent of x
cbrt(x)	Returns the cubic root of x
ceil(x)	Returns x, rounded upwards to the nearest integer
cos(x)	Returns the cosine of x (x is in radians)
cosh(x)	Returns the hyperbolic cosine of x
exp(x)	Returns the value of Ex
floor(x)	Returns x, rounded downwards to the nearest integer
log(x)	Returns the natural logarithm (base E) of x
max(x, y, z, ..., n)	Returns the number with the highest value
min(x, y, z, ..., n)	Returns the number with the lowest value
pow(x, y)	Returns the value of x to the power of y
random()	Returns a random number between 0 and 1
round(x)	Rounds x to the nearest integer
sin(x)	Returns the sine of x (x is in radians)
sinh(x)	Returns the hyperbolic sine of x
sqrt(x)	Returns the square root of x
tan(x)	Returns the tangent of an angle
tanh(x)	Returns the hyperbolic tangent of a number
trunc(x)	Returns the integer part of a number (x)
Comment

js maths

JS Numbers and Math:

Number Properties:
MAX_VALUE
The maximum numeric value representable in JavaScript
MIN_VALUE
Smallest positive numeric value representable in JavaScript
NaN
The “Not-a-Number” value
NEGATIVE_INFINITY
The negative Infinity value
POSITIVE_INFINITY
Positive Infinity value

Number Methods:
toExponential()
Returns a string with a rounded number written as exponential notation
toFixed()
Returns the string of a number with a specified number of decimals
toPrecision()
String of a number written with a specified length
toString()
Returns a number as a string
valueOf()
Returns a number as a number

Math Properties:
E Euler’s number
LN2 The natural logarithm of 2
LN10 Natural logarithm of 10
LOG2E Base 2 logarithm of E
LOG10E Base 10 logarithm of E
PI The number PI
SQRT1_2 Square root of 1/2
SQRT2 The square root of 2

Math Methods:
abs(x)
Returns the absolute (positive) value of x
acos(x)
The arccosine of x, in radians
asin(x)
Arcsine of x, in radians
atan(x)
The arctangent of x as a numeric value
atan2(y,x)
Arctangent of the quotient of its arguments
ceil(x)
Value of x rounded up to its nearest integer
cos(x)
The cosine of x (x is in radians)
exp(x)
Value of Ex
floor(x)
The value of x rounded down to its nearest integer
log(x)
The natural logarithm (base E) of x
max(x,y,z,...,n)
Returns the number with the highest value
min(x,y,z,...,n)
Same for the number with the lowest value
pow(x,y)
X to the power of y
random()
Returns a random number between 0 and 1
round(x)
The value of x rounded to its nearest integer
sin(x)
The sine of x (x is in radians)
sqrt(x)
Square root of x
tan(x)
The tangent of an angle
Comment

math js

function sum(a, b) {
  return a + b;
}

function subtract(a, b) {
  return a - b;
}

function multiply(a, b) {
  return a * b;
}

function divide(a, b) {
  if (b === 0) {
    console.log("can't divide by zero");
  }

  if (a === 0 && b === 0) {
    console.log("undetermined");
  }

  //or this without any IFs
  return a / b;
}
Comment

Javascript Math

const random = Math.random();
const randomMultiple = random * 10;
console.log(randomMultiple)
const randomFloor = Math.floor(randomMultiple);
console.log(randomFloor);
const randomCeil = Math.ceil(randomMultiple);
console.log(randomCeil)
const randomRound = Math.round(randomMultiple)
console.log(randomRound)

//Output:
// 2.545754647061882 randomMultiple
// 2 randomFloor
// 3 randomCeil
// 3 randomRound 
Comment

JavaScript Math Methods

abs(x)	               //Returns the absolute value of x
acos(x)	               //Returns the arccosine of x, in radians
acosh(x)	           //Returns the hyperbolic arccosine of x
asin(x)	               //Returns the arcsine of x, in radians
asinh(x)	           //Returns the hyperbolic arcsine of x
atan(x)	               //Returns the arctangent of x as a numeric value between -PI/2 and PI/2 radians
atan2(y, x)	           //Returns the arctangent of the quotient of its arguments
atanh(x)	           //Returns the hyperbolic arctangent of x
cbrt(x)	               //Returns the cubic root of x
ceil(x)	               //Returns x, rounded upwards to the nearest integer
cos(x)	               //Returns the cosine of x (x is in radians)
cosh(x)	               //Returns the hyperbolic cosine of x
exp(x)	               //Returns the value of Ex
floor(x)	           //Returns x, rounded downwards to the nearest integer
log(x)	               //Returns the natural logarithm (base E) of x
max(x, y, z, ..., n)   //Returns the number with the highest value
min(x, y, z, ..., n)   //Returns the number with the lowest value
pow(x, y)	           //Returns the value of x to the power of y
random()	           //Returns a random number between 0 and 1
round(x)	           //Rounds x to the nearest integer
sign(x)	               //Returns if x is negative, null or positive (-1, 0, 1)
sin(x)	               //Returns the sine of x (x is in radians)
sinh(x)	               //Returns the hyperbolic sine of x
sqrt(x)	               //Returns the square root of x
tan(x)	               //Returns the tangent of an angle
tanh(x)	               //Returns the hyperbolic tangent of a number
trunc(x)	           //Returns the integer part of a number (x)
Comment

math. javascript

function count(string) {
  let string1 = string.split("").sort().join("");
  let counter = 1;
  for (let i = 0; i < string.length; i++) {
    if (string1[i] == string1[i + 1]) {
      counter++;
    } else {
      console.log(string1[i] + " " + counter);
      counter = 1;
    }
  }
}
count("thequickbrownfoxjumpsoverthelazydog");
 Run code snippet
Comment

PREVIOUS NEXT
Code Example
Javascript :: detect javascript disabled 
Javascript :: node import json 
Javascript :: javascript reload section 
Javascript :: react-native-dropdown-picker for form react native 
Javascript :: js modulo not working 
Javascript :: prompt in javascript 
Javascript :: window.focus and window.blur jquery 
Javascript :: Load JSON from file robotframework 
Javascript :: node start is too slow windows 10 
Javascript :: find when webpage was last updated js 
Javascript :: regular expression javascript 
Javascript :: objeto con método javascript 
Javascript :: js two array combining with id neasted 
Javascript :: export to excel on button click in javascript 
Javascript :: how to hide api key in react 
Javascript :: moyenne javascript 
Javascript :: javascript get elements by multiple class names 
Javascript :: get ip address with js 
Javascript :: node check text include in file 
Javascript :: regex match between quotes without escape 
Javascript :: clear inteval 
Javascript :: string to query string javascript 
Javascript :: how to convert json to javascript object 
Javascript :: how to filter multiple values from a json api 
Javascript :: chaining async await 
Javascript :: get search value from reacr route 
Javascript :: set time slots with date in javascript 
Javascript :: in if condition how to set alert music in javascript 
Javascript :: ckeditor ignore contenteditable 
Javascript :: flask sqlalchemy json 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =