Skip to content

Commit 50091d2

Browse files
committed
TheAlgorithms#142 TheAlgorithms#461 Adding Doctests to String/ReverseWords.js
1 parent 2190b92 commit 50091d2

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

String/ReverseWords.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Doctests
3+
*
4+
* > reverseWords('I Love JS')
5+
* 'JS Love I'
6+
* > reverseWords('Hello World')
7+
* 'World Hello'
8+
* > reverseWords('The Algorithms Javascript')
9+
* 'Javascript Algorithms The'
10+
* > reverseWords([])
11+
* ! TypeError
12+
* > reverseWords({})
13+
* ! TypeError
14+
* > reverseWords(null)
15+
* ! TypeError
16+
*/
117
const reverseWords = (str) => {
218
if (typeof str !== 'string') {
319
throw new TypeError('The given value is not a string')

0 commit comments

Comments
 (0)