8000 finished reverseString · borason/javascript-exercises@6cdd20b · GitHub
[go: up one dir, main page]

Skip to content

Commit 6cdd20b

Browse files
committed
finished reverseString
1 parent 090efd1 commit 6cdd20b

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

reverseString/reverseString.js

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

3-
}
4-
5-
module.exports = reverseString
9+
module.exports = reverseString;

reverseString/reverseString.spec.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
const reverseString = require('./reverseString')
1+
const reverseString = require("./reverseString");
22

3-
describe('reverseString', function() {
4-
it('reverses single word', function() {
5-
expect(reverseString('hello')).toEqual('olleh');
3+
describe("reverseString", function() {
4+
it("reverses single word", function() {
5+
expect(reverseString("hello")).toEqual("olleh");
66
});
77

8-
xit('reverses multiple words', function() {
9-
expect(reverseString('hello there')).toEqual('ereht olleh')
10-
})
8+
it("reverses multiple words", function() {
9+
expect(reverseString("hello there")).toEqual("ereht olleh");
10+
});
1111

12-
xit('works with 5930 numbers and punctuation', function() {
13-
expect(reverseString('123! abc!')).toEqual('!cba !321')
14-
})
12+
it("works with numbers and punctuation", function() {
13+
expect(reverseString("123! abc!")).toEqual("!cba !321");
14+
});
1515
});

0 commit comments

Comments
 (0)
0