Skip to content

Commit 7e5d18c

Browse files
committed
new problem added #52
1 parent ecea3e5 commit 7e5d18c

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

L-B/0024 reverseGivenString/README.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Two-dimensional array(L-B)
2+
3+
## Problem
4+
Create a function that takes a string as input and returns the reversed version of the string without using the built-in reverse() method.
5+
6+
## Solution
7+
8+
```javascript
9+
const revMyString = str => {
10+
let revStr = "";
11+
const arrStr = str.split("")
12+
for (let i = arrStr.length - 1; i >= 0; i--) revStr += arrStr[i]
13+
return revStr;
14+
15+
}
16+
```
17+
18+
## How it works
19+
- We split the string into an array of characters
20+
- We loop through the array from the last index to the first index
21+
- We add each character to the revStr variable
22+
- We return the revStr variable
23+
24+
## References
25+
- [Wikipedia](https://en.wikipedia.org/wiki/Fizz_buzz)
26+
27+
## Problem Added By
28+
- [GitHub](https://www.github.com/devvsakib)
29+
30+
31+
32+
## Contributing
33+
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
34+
35+
Please make sure to update tests as appropriate.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const revMyString = str => {
2+
let revStr = "";
3+
4+
const arrStr = str.split("")
5+
6+
for (let i = arrStr.length - 1; i >= 0; i--) revStr += arrStr[i]
7+
8+
9+
return revStr;
10+
11+
}
12+
13+
console.log(revMyString("he"));

0 commit comments

Comments
 (0)