Content-Length: 285217 | pFad | http://github.com/dtphi/TheAlgorithmJavaScript/commit/894a46ca67ed25ba52297d72dbc37d2698ac4763

13 fix: throw error instead of returning it `RailwayTimeConversion` (#1625) · dtphi/TheAlgorithmJavaScript@894a46c · GitHub
Skip to content

Commit 894a46c

Browse files
authored
fix: throw error instead of returning it RailwayTimeConversion (TheAlgorithms#1625)
1 parent 8734dfc commit 894a46c

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

Conversions/RailwayTimeConversion.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
const RailwayTimeConversion = (timeString) => {
1919
// firstly, check that input is a string or not.
2020
if (typeof timeString !== 'string') {
21-
return new TypeError('Argument is not a string.')
21+
throw new TypeError('Argument is not a string.')
2222
}
2323
// split the string by ':' character.
2424
const [hour, minute, secondWithShift] = timeString.split(':')

Conversions/test/RailwayTimeConversion.test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@ test('The RailwayTimeConversion of 11:20:00PM is 23:20:00', () => {
1919
const res = RailwayTimeConversion('11:20:00PM')
2020
expect(res).toEqual('23:20:00')
2121
})
22+
23+
test('The RailwayTimeConversion throws when input is not a string', () => {
24+
expect(() => RailwayTimeConversion(1120)).toThrowError()
25+
})

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/dtphi/TheAlgorithmJavaScript/commit/894a46ca67ed25ba52297d72dbc37d2698ac4763

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy