Advertisement
dimipan80

Simple Calculations

Nov 8th, 2014
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* Write a JavaScript function roundNumber(number) that rounds floating-point number
  2. using Math.round(), Math.floor(). Write a JS program roundingNumbers.js that rounds
  3. a few sample values. */
  4.  
  5. "use strict";
  6.  
  7. function roundNumber(number) {
  8.     console.log('floored number = '+ Math.floor(number));
  9.     console.log('rounded number = ' + Math.round(number));
  10. }
  11.  
  12. roundNumber(22.7);
  13. roundNumber(12.3);
  14. roundNumber(58.7);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement