all tests passed
This commit is contained in:
parent
8b5be1eccf
commit
ba345d6081
|
@ -1,5 +1,12 @@
|
||||||
const reverseString = function() {
|
const reverseString = function(sourceString) {
|
||||||
|
|
||||||
|
let revString = '';
|
||||||
|
|
||||||
|
for (let i = sourceString.length - 1; i >= 0; i--) {
|
||||||
|
revString += sourceString[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
return revString;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = reverseString
|
module.exports = reverseString
|
|
@ -1,18 +1,18 @@
|
||||||
const reverseString = require('./reverseString')
|
const reverseString = require('./reverseString')
|
||||||
|
|
||||||
describe('reverseString', function() {
|
describe('reverseString', function() {
|
||||||
it('reverses single word', function() {
|
it('reverses single word', 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