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

@ -9,6 +9,9 @@
*/
function ReverseStringIterative (string) {
if (typeof string !== 'string') {
throw new TypeError('The given value is not a string')
}
let reversedString = ''
let index
@ -28,6 +31,9 @@ function ReverseStringIterative (string) {
*/
function ReverseStringIterativeInplace (string) {
if (typeof string !== 'string') {
throw new TypeError('The given value is not a string')
}
const _string = string.split('')
for (let i = 0; i < Math.floor(_string.length / 2); i++) {
@ -40,6 +46,4 @@ function ReverseStringIterativeInplace (string) {
return _string.join('')
}
// testing
console.log(ReverseStringIterative('Javascript'))
console.log(ReverseStringIterativeInplace('Javascript'))
export { ReverseStringIterative, ReverseStringIterativeInplace }