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

JavaScriptSource

Search 5,000+ Free JavaScript Snippets

  • Home
  • 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

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

Check if the given value is a number

Check if the given value is a number

Use parseFloat() to try to convert n to a number. Use !Number.isNaN() to check if num is a number.

Math Related

Generating random numbers with JavaScript

Generating random numbers with JavaScript

In this snippet, look at how to get a random integer between two numbers.

Math Related

Check if the given number is even

Check if the given number is even

Check whether a number is odd or even using the modulo (%) operator. Return true if the number is even, false if the number is odd.

Math Related

Check if the given number is odd

Check if the given number is odd

Check whether a number is odd or even using the modulo (%) operator. Return true if the number is odd, false if the number is even.

Math Related

Calculate the nth root of a given number

Calculate the nth root of a given number

Use Math.pow() to calculate x to the power of 1/n which is equal to the nth root of x.

Math Related

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

Primary Sidebar

Popular Posts

Story Generator

IP Grabber – get a users IP address with JavaScript

Simple Calendar

Remove Ads

Astrological Calculator

Copyright © 2025 JavaScriptSource.com

  • About
  • Privacy Policy
  • FAQ
  • Jobs For Developers