Question

Facebook's code changes on Tuesday night have impacted how parseInt works in FBJS. Where I previously used it to convert decimal numbers to straight integers, now it always returns undefined.

For example:

return parseInt(decimalnum);

no longer works. Anyone figured out how we are supposed to round to integers now? Thanks.

Was it helpful?

Solution

Thanks for the report. It's fixed on trunk now; it should be out tomorrow unless there's another push later today.

OTHER TIPS

I suspect that decimalnum is not defined in your function. Try replacing your return with return decimalnum; -- you may still be returning undefined.

parseInt is not for rounding - it actually takes the integer component of a number, or coerces a string to be a number. If you want to round, use Math.round. Depending on your usage, you may find Math.floor or Math.ceil useful.

  1. Math.floor()
  2. Math.ceil()
  3. Math.round()
  4. parseInt()

Did you try parseInt(decimalnum, 10); ?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top