Guest User

Untitled

a guest
Jan 22nd, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. function intToFloat(num, decimal) { [code goes here] }
  2. intToFloat(12, 1) // returns 12.0
  3. intToFloat(12, 2) // returns 12.00
  4. // and so on…
  5.  
  6. function intToFloat(num, decPlaces) { return num.toFixed(decPlaces); }
  7.  
  8. function intToFloat(num, decPlaces) { return num + '.' + Array(decPlaces + 1).join('0'); }
  9.  
  10. xAsString = (Number.isInteger(x)) ? (x + ".0") : (x.toString());
Add Comment
Please, Sign In to add comment