Skip to content

Commit

Permalink
conversion: liters to US gallons (TheAlgorithms#1255)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lcvieira2001 authored Oct 31, 2022
1 parent 8cbaf2e commit b634aa5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Conversions/LitersToUSGallons.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* This function converts liters to US gallons
* https://en.wikipedia.org/wiki/Gallon
* @constructor
* @param {number} liters - Amount of liters to convert to gallons
*/
const litersToUSGallons = (liters) => {
return liters / 3.785411784
}

export default litersToUSGallons
5 changes: 5 additions & 0 deletions Conversions/test/LitersToUSGallons.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import litersToUSGallons from '../LitersToUSGallons'

test('Convert 50 liters to US gallons', () => {
expect(parseFloat(litersToUSGallons(50).toFixed(2))).toBe(13.21)
})

0 comments on commit b634aa5

Please sign in to comment.