numbers-words
Version:
numbers-words is a useful package when you are working with numbers. It can converts numbers to words, format numbers and more in the upcoming versions!
17 lines (12 loc) • 435 B
JavaScript
const maxNumber = require("../core/maxNumber.js");
function toSciNot(number) {
if (isNaN(number)) throw new Error("Expected a number");
if (number > maxNumber) throw new Error("Number can not be greater than" + maxNumber);
if (number === 0) {
return "0";
}
// Gng should I make the decimals customazible
const scientificNotation = number.toExponential();
return scientificNotation;
}
module.exports = toSciNot;