We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bd483c1 commit 9be9270Copy full SHA for 9be9270
Sprint-1/exercises/decimal.js
@@ -7,3 +7,15 @@ const num = 56.5678;
7
// Create a variable called roundedNum and assign to it an expression that evaluates to 57 ( num rounded to the nearest whole number )
8
9
// Log your variables to the console to check your answers
10
+
11
12
+const wholeNumberPart = Math.floor(num);
13
+console.log(` Whole number = ${wholeNumberPart}`);
14
15
+const decimalPart = num - wholeNumberPart;
16
+console.log(` Decimal part = ${decimalPart.toFixed(4)}`); // toFixed(4) to show 4 decimal places instead of whole number
17
18
+console.log(typeof(wholeNumberPart)); //confirm that decimalPart is a number
19
20
+const roundedNum = Math.round(num);
21
+console.log(` Rounded number = ${roundedNum}`);
0 commit comments