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 :: axios post request javascript 
Javascript :: jason in javascript 
Javascript :: javascript select element with two classes 
Javascript :: how to include script file in javascript with javascript 
Javascript :: ref in functional components 
Javascript :: async foreach 
Javascript :: get json data into array of object 
Javascript :: how to get os theme value in javascript 
Javascript :: parseint js 
Javascript :: nan javascript 
Javascript :: html js how to draw on screen 
Javascript :: json loop in js 
Javascript :: javascript fill 2 dimensional array 
Javascript :: Capturing enter in javascript 
Javascript :: ssg full form in nextjs 
Javascript :: react cdn 
Javascript :: populate example in mongoose 
Javascript :: get all child element of class javascript 
Javascript :: mod operation in shopify 
Javascript :: react form hook npm 
Javascript :: js copy values from one array to another node new 
Javascript :: react router link with params 
Javascript :: how to make a check if 50% of letters are capital in discord js 
Javascript :: command to start a new react app using vite 
Javascript :: js fetch catch 401 
Javascript :: today date selected in datepicker 
Javascript :: javascript objectentries 
Javascript :: paragraph antd 
Javascript :: react mui icons 
Javascript :: get all object key names 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =