• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
JavaScriptSource

JavaScriptSource

Search 5,000+ Free JavaScript Snippets

  • Home
  • Forum
  • Browse Snippets
    • Addon
    • Ajax
    • Buttons
    • Cookies
    • CSS
    • Featured
    • Forms
    • Games
    • Generators
    • Image Effects
    • Math Related
    • Miscellaneous
    • Multimedia
    • Navigation
    • Page Details
    • Passwords
    • Text Effects
    • Time & Date
    • User Details
Home / Archives for Math Related

Math Related

Generate a random number in a given range with JavaScript

Generate a random number in a given range

The following snippet returns a random number between min (inclusive) and max (exclusive).

Math Related

Get the largest number from a set of numbers

Get the largest number from a set of numbers

Math.max() returns the largest number from a set of numbers. Pass each number in as an argument.

Math Related

Return the largest integer less than or equal to a number

Return the largest integer less than or equal to a number

Returns the largest integer (whole number) less than or equal to a number.

Math Related

Get the absolute value of a number with JavaScript

Get the absolute value of a number

Get the absolute (positive) value of a number.

Math Related

Format a number to a fixed number of decimal places

Format a number to a fixed number of decimal places

Format a number to a fixed number of decimal places. Pass in the number of decimal places as an argument

Math Related

Convert a string into an integer (a whole number)

Convert a string into an integer (a whole number)

Convert a string into an integer (a whole number).

Math Related

Take a number and return it in the specified currency formatting

Take a number and returns it in the specified currency formatting

Use Intl.NumberFormat to enable country / currency sensitive formatting.

Math Related

The Exponent Operator

The Exponent Operator

Do you useMath.pow() to raise a number to a power? Did you know you can use the exponent operator ** as well?

Math Related

Calculate the midpoint between two pairs of (x,y) points

Calculate the midpoint between two pairs of (x,y) points

Destructure the array to get x1, y1, x2 and y2. Calculate the midpoint for each dimension by dividing the sum of the two endpoints by 2.

Math Related

Round a number to a specified amount of digits

Round a number to a specified amount of digits

Use Math.round() and template literals to round the number to the specified number of digits. Omit the second argument, decimals, to round to an integer.

Math Related

  • Go to page 1
  • Go to page 2
  • Go to page 3
  • Go to Next Page »

Primary Sidebar

FREE UPDATES!

Get the latest updates in your inbox for FREE!

Popular Posts

Story Generator

IP Grabber

Simple Calendar

Remove Ads

Astrological Calculator

Copyright © 2022 JavaScriptSource.com

  • About
  • Privacy Policy
  • Submit
  • FAQ
  • Jobs For Developers
  • Contact Us