8000 Add Solution to Exercise 03 · TezzGit/javascript-exercises@0b80324 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0b80324

Browse files
committed
Add Solution to Exercise 03
All test have passed
1 parent 0b90a4d commit 0b80324

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

03_reverseString/reverseString.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1-
const reverseString = function() {
2-
1+
const reverseString = function (str) {
2+
if (str.length < 1) {
3+
return ""
4+
}
5+
let reversedString = "";
6+
for (let i = str.length - 1; i >= 0; i--) {
7+
reversedString += str[i];
8+
}
9+
return reversedString
310
};
411

512
// Do not edit below this line

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)
0