Skip to content

Commit

Permalink
convertion: ounce to kilogram (TheAlgorithms#1248)
Browse files Browse the repository at this point in the history
* Added ounces to kilograms convertion

* Added PR suggestions

* changed to export default
  • Loading branch information
Lcvieira2001 authored Oct 31, 2022
1 parent 7256e53 commit 8cbaf2e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
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)
})

0 comments on commit 8cbaf2e

Please sign in to comment.