function justEnoughPrecision(n) {
if (typeof n !== "number") throw Error("argument must be a number");
const str = n.toString();
if (n === ~~n) return str;
const [left, right] = str.split(".");
const leftSideDigits = left
.split("")
.filter((l) => l !== "-")
.join("").length;
const remainingPrecision = Math.max(0, 5 - leftSideDigits);
const remainingFloatingPoints = right.slice(0, remainingPrecision);
return `${left}${remainingFloatingPoints.length ? "." : ""}${
remainingFloatingPoints || ""
}`;
}