-
Notifications
You must be signed in to change notification settings - Fork 91
/
Copy pathFirst Reverse
22 lines (19 loc) · 1.48 KB
/
First Reverse
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/***************************************************************************************
* *
* CODERBYTE BEGINNER CHALLENGE *
* *
* First Reverse *
* Have the function FirstReverse() take the str parameter being passed and return *
* the string in reversed order. *
* *
* SOLUTION *
* There is no reverse function for Strings in JavaScript BUT there is a reverse() *
* function for arrays. I will use this built-in function for my solution. *
* 1) Convert the string to an array using the split() function. *
* 2) Use Array Reverse() function. *
* 3) Convert array back to a string using join() function. *
* *
***************************************************************************************/
function FirstReverse(str) {
return str.split("").reverse().join("");
}