forked from TheAlgorithms/JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
convertion: ounce to kilogram (TheAlgorithms#1248)
* Added ounces to kilograms convertion * Added PR suggestions * changed to export default
- Loading branch information
1 parent
7256e53
commit 8cbaf2e
Showing
2 changed files
with
16 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* This function converts ounces to kilograms | ||
* https://en.wikipedia.org/wiki/Ounce | ||
* @constructor | ||
* @param {number} oz - Amount of ounces to convert to kilograms | ||
*/ | ||
const ouncesToKilograms = (oz) => { | ||
return oz * 28.3498 / 1000 | ||
} | ||
|
||
export default ouncesToKilograms |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import ouncesToKilograms from '../OuncesToKilograms' | ||
|
||
test('Convert 60 ounces to kilograms', () => { | ||
expect(parseFloat(ouncesToKilograms(60).toFixed(3))).toBe(1.701) | ||
}) |