Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Commit

Permalink
Add interview examples
Browse files Browse the repository at this point in the history
  • Loading branch information
sicktastic committed Nov 22, 2017
1 parent 48c00c9 commit f8e4e76
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions algorithms/reversestring/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,21 @@
// .join('')
// }

function reverse(str) {
let reversed = '';
// function reverse(str) {
// let reversed = '';

// for (let character of str) {
// reversed = character + reversed;
// }

for (let character of str) {
reversed = character + reversed;
}
// return reversed;
// }

return reversed;
function reverse(str) {
debugger;
return str.split('').reduce((rev, char) => char+ rev, '');
}

reverse('Anthony');

module.exports = reverse;

0 comments on commit f8e4e76

Please sign in to comment.