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.
2 parents efc427e + ef78fce commit 901432eCopy full SHA for 901432e
Maths/decimalIsolate.js
@@ -0,0 +1,17 @@
1
+/*
2
+ * function isolates the decimal part of a number.
3
+ * Take the number and subtract it from the floored number.
4
+ * Return the result.
5
+ */
6
+
7
+const decimalIsolate = (number) => {
8
+ const ans = parseFloat((number + '').replace(/^[-\d]+./, '.'))
9
+ return isNaN(ans) === true ? 0 : ans
10
+}
11
12
+// testing
13
+console.log(decimalIsolate(35.345))
14
+console.log(decimalIsolate(56.879))
15
+console.log(decimalIsolate(89.5643))
16
+console.log(decimalIsolate(38.00))
17
+console.log(decimalIsolate(33))
0 commit comments