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 :: discord js slash command 
Javascript :: file-saver npm 
Javascript :: dom methods 
Javascript :: slice example 
Javascript :: how to stop requestanimationframe in javascript 
Javascript :: instantiate js 
Javascript :: Javascript async await & Promise 
Javascript :: jwt decode 
Javascript :: javascript this keyword 
Javascript :: average javascript 
Javascript :: array.filter 
Javascript :: Event Delegation Example In JavaScript 
Javascript :: sweet alert 2 
Javascript :: sort javascript 
Javascript :: react setstate synchronous 
Javascript :: ReferenceError: document is not defined 
Javascript :: express rate limit 
Javascript :: how can i use exact in react router dom v6 
Javascript :: map duplicate keys JS 
Javascript :: Child nodes in a node 
Javascript :: use next() in node js 
Javascript :: understanding currying 
Javascript :: context api in react 
Javascript :: destructuring javascript 
Javascript :: typedjs 
Javascript :: useReducer Hooks 
Javascript :: status discored jks 
Javascript :: parsely ignores hidden field 
Javascript :: how to access array of objects in javascript 
Javascript :: alert on right click jquery 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =