Skip to content

convertion: ounce to kilogram #1248

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Conversions/OuncesToKilograms.js
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
5 changes: 5 additions & 0 deletions Conversions/test/OuncesToKilogram.test.js
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)
})