Extra Challange in WorkAround Explorer

Hello there, I want to ask if my code is written good (it works without any troubles)and if not please give me some advice on how to write better! :slightly_smiling_face: . I hope admins have all of the other code already saved and I can just put my “utitilies.js” here. So, here it is:

const formatWithComma = (intPart, i) => {
  let intPartAfter;
  if (i === 3) {
    intPartAfter = intPart.join('');
  } else {
    while (i > 3) {
      i -= 3;
      intPart.splice(i, 0, ',');
      intPartAfter = intPart.join('');
    }
  }
  return intPartAfter;
};
const checkIsNumber = (typeOfData) => {
  if (typeof typeOfData === 'number') {
    typeOfData = typeOfData.toString();
    return typeOfData;
  } else if (typeof typeOfData === 'string') {
    return typeOfData;
  } else return 'This is not a string or number';
};

const formatNumber = (number) => {
  number = checkIsNumber(number);
  const arrNum = number.split('.');
  const intPart = arrNum[0].split('');
  let i = intPart.length;
  number = formatWithComma(intPart, i);
  arrNum[0] = number;
  return arrNum.join('.');
};
export default formatNumber;