• 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

3 Ways To Round a Number to 2 Decimal Places in JavaScript

How To Round a Number to 2 Decimal Places in JavaScript

In this article, we will look at 3 different ways to round a number to 2 decimal places in JavaScript.

Math Related

The JavaScript function Math.pow()

The JavaScript function Math.pow()

The Math.pow() function in JavaScript is used to raise a number (called the base) to a certain power (called the exponent). The syntax for using this function is Math.pow(base, exponent). For example, to raise 2 to the power of 3, you would use the following code: In this example, 2 is the base and 3 […]

Basics, Math Related

The JavaScript function Math.floor()

The JavaScript function Math.floor()

The JavaScript function Math.floor() is used to round a number down to the nearest integer. This function takes a single argument, which is the number that you want to round down. For example, if you wanted to round the number 4.7 down to the nearest integer, you would use the following code: As you can […]

Basics, Math Related

The JavaScript function Math.abs()

The JavaScript function Math.abs()

The JavaScript function Math.abs() is a built-in function that returns the absolute value of a number. The absolute value of a number is its distance from zero, regardless of whether the number is positive or negative. Here is an example of how to use the Math.abs() function: In the above example, num1 is assigned the […]

Basics, Math Related

Arithmetic Operators in JavaScript

Arithmetic Operators in JavaScript

JavaScript has several arithmetic operators that are used to perform mathematical operations on numbers. These operators include: Addition (+): This operator is used to add two or more numbers together. Subtraction (-): This operator is used to subtract one number from another. Multiplication (*): This operator is used to multiply two or more numbers together. […]

Math Related, Basics

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

  • 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