loop solution for exercise 3

This commit is contained in:
LoptrSir 2022-03-08 11:50:07 -08:00
parent 6a4d5f7e11
commit 180c199870
2 changed files with 11 additions and 4 deletions

View File

@ -1,6 +1,13 @@
const reverseString = function() {
const reverseString = function(string) {
let backString = '';
for (i = string.length - 1; i >= 0; i--) {
backString += string[i];
}
console.log(backString);
return backString;
};
reverseString('Howdy');
// Do not edit below this line
module.exports = reverseString;

View File

@ -5,14 +5,14 @@ describe('reverseString', () => {
expect(reverseString('hello')).toEqual('olleh');
});
test.skip('reverses multiple words', () => {
test('reverses multiple words', () => {
expect(reverseString('hello there')).toEqual('ereht olleh')
})
test.skip('works with numbers and punctuation', () => {
test('works with numbers and punctuation', () => {
expect(reverseString('123! abc!')).toEqual('!cba !321')
})
test.skip('works with blank strings', () => {
test('works with blank strings', () => {
expect(reverseString('')).toEqual('')
})
});