Skip to content

Instantly share code, notes, and snippets.

@nocodesupplyco
Created December 19, 2022 16:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nocodesupplyco/a7aed0f6efecf01bd049324e92e2c8b7 to your computer and use it in GitHub Desktop.
Save nocodesupplyco/a7aed0f6efecf01bd049324e92e2c8b7 to your computer and use it in GitHub Desktop.
Round Number to Nearest Integer
// Round number to the nearest whole integer
var theNumber = 18510.01;
var roundedNumber = Math.round(theNumber); // will output 18500
// Round number to the nearest thousand
var theNumber = 18510.01;
var roundedNumber = Math.round(theNumber/1000)*1000; //will output 19000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment