mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-05 00:01:37 +08:00
convertion: ounce to kilogram (#1248)
* Added ounces to kilograms convertion * Added PR suggestions * changed to export default
This commit is contained in:
11
Conversions/OuncesToKilograms.js
Normal file
11
Conversions/OuncesToKilograms.js
Normal file
@ -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
|
5
Conversions/test/OuncesToKilogram.test.js
Normal file
5
Conversions/test/OuncesToKilogram.test.js
Normal file
@ -0,0 +1,5 @@
|
||||
import ouncesToKilograms from '../OuncesToKilograms'
|
||||
|
||||
test('Convert 60 ounces to kilograms', () => {
|
||||
expect(parseFloat(ouncesToKilograms(60).toFixed(3))).toBe(1.701)
|
||||
})
|
Reference in New Issue
Block a user