Scientific Notation Formatter

Formats a number into scientific notation.

Contributed by @itsbrunodev

javascript
function formatScientific(value, decimalPlaces = 2) {
  return value.toExponential(decimalPlaces);
}
javascript
formatScientific(123456); // "1.23e+5"
GitHubEdit on GitHub