8000 reverse string assignment finished · ambydau/javascript-exercises@1c620d7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1c620d7

Browse files
committed
reverse string assignment finished
1 parent d0706d3 commit 1c620d7

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

reverseString/reverseString.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
const reverseString = function() {
2-
1+
const reverseString = function(str) {
2+
let strArray = [...str];
3+
let reversedStr = "";
4+
for(let i = strArray.length - 1; i >= 0; i--){
5+
reversedStr += strArray[i];
6+
}
7+
return reversedStr;
38
}
49

510
module.exports = reverseString

reverseString/reverseString.spec.js

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

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

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

0 commit comments

Comments
 (0)
0