Skip to content

Commit 2057787

Browse files
problme 65 solved
1 parent e219476 commit 2057787

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

problem65/problme65.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,29 @@
22

33
/* Example Input: "hello world" Example Output: "dlrow olleh" */
44

5+
/* ----------------------------
6+
Solution One:
7+
------------------------------- */
8+
9+
function textReverser(text){
10+
11+
let reverseText = '';
12+
13+
for(let i = text.length - 1; i >= 0; i--){
14+
const letter = text[i];
15+
reverseText = reverseText + letter;
16+
}
17+
18+
return reverseText;
19+
}
20+
21+
console.log(textReverser("hello world"));
22+
23+
24+
/* ----------------------------
25+
Solution Two:
26+
------------------------------- */
27+
28+
const stringReverser = text => text.split('').reduce((previous, present) => present + previous, '' );
29+
30+
console.log(stringReverser("hello world"));

0 commit comments

Comments
 (0)