Within my function, I am tasked with returning a string that includes a decimal number. If the number is whole, I simply return it as is along with additional strings. However, if it's not whole, I include the number along with the string up to 2 decimal places. My current code is functioning correctly without any hitches. However, I find myself pondering whether my method of converting to decimal places and the way I handle returning the string adhere to best practices.
function getDec() {
let size_new: string;
while (size >= 1000) {
// Perform calculations
size_new = size_new / 1000;
}
// Determine if size is a decimal or not
return size_in_decimal;
}