Added tests for Strings algorithms (#390)

* test: added tests for check anagram function
This commit is contained in:
Alexandre Xavier
2020-10-04 14:38:48 -03:00
committed by GitHub
parent e156fe36a1
commit c5fc353c32
13 changed files with 8250 additions and 22 deletions

View File

@ -1,4 +1,7 @@
const reverseWords = (str) => {
if (typeof str !== 'string') {
throw new TypeError('The given value is not a string')
}
// Split string into words
// Ex. "I Love JS" => ["I", "Love", "JS"]
const words = str.split(' ')
@ -10,6 +13,4 @@ const reverseWords = (str) => {
return reversedWords.join(' ')
}
// testing
console.log(reverseWords('I Love JS'))
console.log(reverseWords('My Name Is JavaScript'))
export { reverseWords }