solved reverseString exercises
This commit is contained in:
parent
ffc0b766c8
commit
18d7b040d6
|
@ -1,5 +1,9 @@
|
||||||
const reverseString = function() {
|
const reverseString = function(str) {
|
||||||
|
let rts='';
|
||||||
|
for (let index = str.length-1; index>=0; index--) {
|
||||||
|
rts=rts + str.substr(index,1);
|
||||||
|
}
|
||||||
|
return rts;
|
||||||
}
|
}
|
||||||
|
|
||||||
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