Skip to content

Commit 41c8b2f

Browse files
committed
Resolve tests for lesson 3
1 parent 917b5c1 commit 41c8b2f

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

03_reverseString/reverseString.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
1-
const reverseString = function() {
2-
1+
const reverseString = function(string) {
2+
stringAsArrayBackwards = []
3+
for (let i = string.length; i > 0; i--) {
4+
let character = string.charAt(i - 1);
5+
stringAsArrayBackwards.push(character);
6+
};
7+
let backwardsString = stringAsArrayBackwards.toString();
8+
return backwardsString.replace(/,/g,"")
39
};
10+
/*
11+
make string into array
12+
loop through each letter of string and push to array
13+
using length of string
14+
*/
415

516
// Do not edit below this line
617
module.exports = reverseString;

03_reverseString/reverseString.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ describe('reverseString', () => {
55
expect(reverseString('hello')).toEqual('olleh');
66
});
77

8-
test.skip('reverses multiple words', () => {
8+
test('reverses multiple words', () => {
99
expect(reverseString('hello there')).toEqual('ereht olleh')
1010
})
1111

12-
test.skip('works with numbers and punctuation', () => {
12+
test('works with numbers and punctuation', () => {
1313
expect(reverseString('123! abc!')).toEqual('!cba !321')
1414
})
15-
test.skip('works with blank strings', () => {
15+
test('works with blank strings', () => {
1616
expect(reverseString('')).toEqual('')
1717
})
1818
});

0 commit comments

Comments
 (0)