Skip to content

Commit

Permalink
conversion: liters to imperial gallons (TheAlgorithms#1256)
Browse files Browse the repository at this point in the history
* Added liters to imperial gallons conversion

* Fixed documentation @see

* Pr suggestion
  • Loading branch information
Lcvieira2001 authored Oct 31, 2022
1 parent 863185d commit cc0700f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Conversions/LitersToImperialGallons.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* This function converts liters to imperial gallons
* @constructor
* @param {number} liters - Amount of liters to convert to gallons
* @see https://en.wikipedia.org/wiki/Gallon
*/
const litersToImperialGallons = (liters) => {
return liters / 4.54609
}

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

test('Convert 25 liters to imperial gallons', () => {
expect(parseFloat(litersToImperialGallons(25).toFixed(2))).toBe(5.5)
})

0 comments on commit cc0700f

Please sign in to comment.