DEV Community

Discussion on: 9 Extremely Powerful JavaScript Hacks

Collapse
 
gustvandewal profile image
Gust van de Wal

"You can change the function by wrapping the returned value in parens and multiply by 1 at the end if you need a number returned rather than a string"

But the function already has a part that freshly generates the raw rounded number: Math.round(num * 10) / 10. Just leaving that part will do; no need to generate a number -> cast to string -> cast to number