JavaScript moneyFormat() function
Bad variable names. dollars and cents would be more appropriate that firsthalf and secondhalf... I mean, c'mon, these variables don't represent "halfs" of anything. float isn't very descriptive either. Perhaps rawvalue would be better, and maybe result_buffer would be better than answer.
The entire code for whole numbers is unnecessary. When you run toFixed() on a whole number it becomes a float (string) anyway. 
Rather than creating a new variable and arbitrarily swapping between let and const, why not just reassign float (or in my version, raw_value). You won't need it anymore after that anyway.
You might wanna consider casting it to a float in case a string is passed to the function, in which case your toFixed would fail.
It doesn't make a hue difference whether you declare your variables at the top or as needed when you're working on a small function, but be consistent. And if you do declare them all at the top, I would suggest doing it in a single statement for a small performance boost. In this case, I would personally just declare them as you go to keep the function concise.
When you're doing a backwards loop like that you don't need all three statements in the for loop. You could just do for (let i = firstHalf.length; i--;). That said, looping backwards and then reversing (or looping at all for that matter) makes for smelly code. You can just use a little regular expression to chunk the chars up: /.{1,3}/g
Don't reassign a variable just to return it, just return it. It's less work for the computer that way.




const moneyFormat = (raw_value) =&gt; {
  raw_value = parseFloat(raw_value).toFixed(2).split('.');
  let dollars = raw_value[0],
    cents = '.' + raw_value[1],
    format_buffer = dollars
      .split('').reverse().join('') // reverse it
      .match(/.{1,3}/g) // chunk it
      .map(c=&gt;c.split('').reverse().join(''))
      .reverse(); // reverse it again
  return format_buffer.join(' ') + cents;
}

console.log(moneyFormat(2310000.159897)); // '2 310 000.16'
console.log(moneyFormat(1600)); // '1 600.00'
console.log(moneyFormat("1600"));
console.log(moneyFormat("234123.2134123"));