Skip to content

Commit

Permalink
first exercise - reverse string
Browse files Browse the repository at this point in the history
  • Loading branch information
mhipley committed Jan 28, 2020
1 parent f053cd1 commit dcfecfd
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion exercises/reversestring/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
// reverse('hello') === 'olleh'
// reverse('Greetings!') === '!sgniteerG'

function reverse(str) {}
function reverse(str) {
var strRev = "";

for (var i = 0; i <= str.length; i++) {
strRev = str.charAt(i) + strRev;
}

return strRev;
}

module.exports = reverse;

0 comments on commit dcfecfd

Please sign in to comment.