Added solution for reverseString
This commit is contained in:
parent
8aefa82522
commit
2a699ab109
|
@ -1,5 +1,9 @@
|
||||||
const reverseString = function() {
|
const reverseString = function(str) {
|
||||||
|
let temp = str.split("");
|
||||||
|
let temp2 = temp.reverse();
|
||||||
|
let ans = temp2.join("");
|
||||||
|
|
||||||
|
return ans;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = reverseString
|
module.exports = reverseString
|
||||||
|
|
|
@ -5,14 +5,14 @@ describe('reverseString', function() {
|
||||||
expect(reverseString('hello')).toEqual('olleh');
|
expect(reverseString('hello')).toEqual('olleh');
|
||||||
});
|
});
|
||||||
|
|
||||||
xit('reverses multiple words', function() {
|
it('reverses multiple words', function() {
|
||||||
expect(reverseString('hello there')).toEqual('ereht olleh')
|
expect(reverseString('hello there')).toEqual('ereht olleh')
|
||||||
})
|
})
|
||||||
|
|
||||||
xit('works with numbers and punctuation', function() {
|
it('works with numbers and punctuation', function() {
|
||||||
expect(reverseString('123! abc!')).toEqual('!cba !321')
|
expect(reverseString('123! abc!')).toEqual('!cba !321')
|
||||||
})
|
})
|
||||||
xit('works with blank strings', function() {
|
it('works with blank strings', function() {
|
||||||
expect(reverseString('')).toEqual('')
|
expect(reverseString('')).toEqual('')
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue