function round(value, decimals) {
  const numberContainsExponent = value?.toString().includes('e');
  if (typeof decimals === 'undefined' || numberContainsExponent) {
    return Number(value);
  }
  return Number(`${Math.round(Number(`${value}e${decimals}`))}e-${decimals}`);
}
Rounding problem can be avoided by using numbers represented in exponential notation
@param {number} value to be rounded up
@param {number | undefined} decimals amount of decimals to keep
@return {number} new value with rounded up decimals