mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-07 19:17:33 +08:00
Added decimalIsolate file.
This commit is contained in:
15
Maths/decimalIsolate.js
Normal file
15
Maths/decimalIsolate.js
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
/*
|
||||||
|
* function isolates the decimal part of a number.
|
||||||
|
* Take the number and subtract it from the floored number.
|
||||||
|
* Return the result.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const decimalIsolate = (number) => {
|
||||||
|
return number - Math.floor(number)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// testing
|
||||||
|
console.log(decimal_isolate(35.345))
|
||||||
|
console.log(decimal_isolate(56.879))
|
||||||
|
console.log(decimal_isolate(89.5643))
|
Reference in New Issue
Block a user