Added solution for reverseString

This commit is contained in:
Nidhish1407 2020-08-24 22:36:24 +05:30
parent 8aefa82522
commit 2a699ab109
2 changed files with 9 additions and 5 deletions

View File

@ -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

View File

@ -5,14 +5,14 @@ describe('reverseString', function() {
expect(reverseString('hello')).toEqual('olleh');
});
xit('reverses multiple words', function() {
it('reverses multiple words', function() {
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')
})
xit('works with blank strings', function() {
it('works with blank strings', function() {
expect(reverseString('')).toEqual('')
})
});