Skip to content

Commit 02ddab6

Browse files
reversewordsina string
1 parent 67be6c3 commit 02ddab6

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//input parameter of the function --> string
2+
//return reversed string
3+
//examples
4+
5+
function reverse(string) {
6+
//todo split into an array based on spacess
7+
//todo reverse
8+
return string.split(" ").reverse().join(" ");
9+
}
10+
11+
console.log(reverse("I am an expert at this"));
12+
console.log(reverse("This is so easy"));
13+
console.log(reverse("no one cares"));
14+
console.log(reverse(""));
15+
console.log(reverse("Codewars"));

0 commit comments

Comments
 (0)