reverseString All done
This commit is contained in:
parent
7ab3796032
commit
e8cdd37d95
|
@ -1,5 +1,13 @@
|
|||
const reverseString = function() {
|
||||
const reverseString = function(string) {
|
||||
|
||||
|
||||
let revString = '';
|
||||
|
||||
for (let i = string.length - 1; i >= 0; i--) {
|
||||
revString += string.charAt(i);
|
||||
}
|
||||
|
||||
return revString;
|
||||
}
|
||||
|
||||
module.exports = reverseString
|
||||
module.exports = reverseString
|
|
@ -1,18 +1,18 @@
|
|||
const reverseString = require('./reverseString')
|
||||
|
||||
describe('reverseString', function() {
|
||||
it('reverses single word', function() {
|
||||
expect(reverseString('hello')).toEqual('olleh');
|
||||
});
|
||||
it('reverses single word', function() {
|
||||
expect(reverseString('hello')).toEqual('olleh');
|
||||
});
|
||||
|
||||
xit('reverses multiple words', function() {
|
||||
expect(reverseString('hello there')).toEqual('ereht olleh')
|
||||
})
|
||||
it('reverses multiple words', function() {
|
||||
expect(reverseString('hello there')).toEqual('ereht olleh')
|
||||
})
|
||||
|
||||
xit('works with numbers and punctuation', function() {
|
||||
expect(reverseString('123! abc!')).toEqual('!cba !321')
|
||||
})
|
||||
xit('works with blank strings', function() {
|
||||
expect(reverseString('')).toEqual('')
|
||||
})
|
||||
});
|
||||
it('works with numbers and punctuation', function() {
|
||||
expect(reverseString('123! abc!')).toEqual('!cba !321')
|
||||
})
|
||||
it('works with blank strings', function() {
|
||||
expect(reverseString('')).toEqual('')
|
||||
})
|
||||
});
|
Loading…
Reference in New Issue