Skip to content

Commit 8cbaf2e

Browse files
authored
convertion: ounce to kilogram (TheAlgorithms#1248)
* Added ounces to kilograms convertion * Added PR suggestions * changed to export default
1 parent 7256e53 commit 8cbaf2e

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

Conversions/OuncesToKilograms.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* This function converts ounces to kilograms
3+
* https://en.wikipedia.org/wiki/Ounce
4+
* @constructor
5+
* @param {number} oz - Amount of ounces to convert to kilograms
6+
*/
7+
const ouncesToKilograms = (oz) => {
8+
return oz * 28.3498 / 1000
9+
}
10+
11+
export default ouncesToKilograms
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import ouncesToKilograms from '../OuncesToKilograms'
2+
3+
test('Convert 60 ounces to kilograms', () => {
4+
expect(parseFloat(ouncesToKilograms(60).toFixed(3))).toBe(1.701)
5+
})

0 commit comments

Comments
 (0)