Skip to content

Commit 0ec3582

Browse files
authored
Adds strings algorythms, such as anagrams, capitalizer, palindrome… (#5)
Adds strings algorythms, such as anagrams, capitalizer, palindrome, reverse, vowels
2 parents 0650bee + c1fdc8b commit 0ec3582

17 files changed

+305
-5
lines changed

docs/readme.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ npm install allalgorithms
4545
```js
4646
const allalgorithms = require('allalgorithms');
4747

48-
arr = [77, 2, 10, -2, 1, 7]
48+
const arr = [77, 2, 10, -2, 1, 7];
4949

5050
console.log(allalgorithms.sorting.bubbleSort(arr));
5151
// -> [-2, 1, 2, 7, 10, 77]
@@ -57,6 +57,13 @@ console.log(allalgorithms.sorting.bubbleSort(arr));
5757
- [Bubble Sort](https://js.allalgorithms.com/sorting/bubble-sort)
5858
- [Merge Sort](https://js.allalgorithms.com/sorting/merge-sort)
5959

60+
- **Strings**
61+
- [Reverse](https://js.allalgorithms.com/strings/reverse)
62+
- [Capitalize](https://js.allalgorithms.com/strings/capitalize)
63+
- [Palindrome](https://js.allalgorithms.com/strings/palindrome)
64+
- [Vowels](https://js.allalgorithms.com/strings/vowels)
65+
- [Anagrams](https://js.allalgorithms.com/strings/anagrams)
66+
6067
# Related
6168

6269
- [allalgorithms-python](https://github.com/abranhe/allalgorithms-python): All ▲lgorithms Python library

docs/sorting/bogo-sort.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ npm install allalgorithms
1313
```js
1414
const allalgorithms = require('allalgorithms');
1515

16-
arr = [77, 2, 10, -2, 1, 7]
16+
const arr = [77, 2, 10, -2, 1, 7];
1717

1818
console.log(allalgorithms.sorting.bogoSort(arr))
1919
// -> [-2, 1, 2, 7, 10, 77]

docs/sorting/bubble-sort.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ npm install allalgorithms
1313
```js
1414
const allalgorithms = require('allalgorithms');
1515

16-
arr = [77, 2, 10, -2, 1, 7]
16+
const arr = [77, 2, 10, -2, 1, 7];
1717

1818
console.log(allalgorithms.sorting.bubbleSort(arr));
1919
// -> [-2, 1, 2, 7, 10, 77]

docs/sorting/merge-sort.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ npm install allalgorithms
1313
```js
1414
const allalgorithms = require('allalgorithms');
1515

16-
arr = [77, 2, 10, -2, 1, 7]
16+
const arr = [77, 2, 10, -2, 1, 7];
1717

1818
console.log(allalgorithms.sorting.mergeSort(arr))
1919
// -> [-2, 1, 2, 7, 10, 77]

docs/strings/anagrams.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Anagrams
2+
3+
An anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.[1] For example, the word anagram can be rearranged into nag a ram, or the word binary into brainy or the word adobe into abode.
4+
5+
## Install
6+
7+
```
8+
npm install allalgorithms
9+
```
10+
11+
## Usage
12+
13+
```js
14+
const allalgorithms = require('allalgorithms');
15+
16+
const strA = 'RAIL? SAFETY';
17+
const strB = 'fairy tales';
18+
19+
console.log(allalgorithms.strings.anagrams(strA, strB));
20+
// -> true
21+
```
22+
23+
## API
24+
25+
### anagrams(strA, strB)
26+
27+
> Returns true if strings are anagrams
28+
29+
##### Params:
30+
31+
- `strA`: First string
32+
- `strB`: Second string

docs/strings/capitalize.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Capitalize
2+
3+
Method converts the first character of a string to capital (uppercase) letter. If the string has its first character as capital, then it returns the original string
4+
5+
## Install
6+
7+
```
8+
npm install allalgorithms
9+
```
10+
11+
## Usage
12+
13+
```js
14+
const allalgorithms = require('allalgorithms');
15+
16+
const str = 'framework for managing your configuration';
17+
18+
console.log(allalgorithms.strings.capitalize(str));
19+
// -> Framework For Managing Your Configuration
20+
```
21+
22+
## API
23+
24+
### capitalize(str)
25+
26+
> Returns capitalized string
27+
28+
##### Params:
29+
30+
- `str`: Non-capitalized string

docs/strings/palindrome.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Palindrome
2+
3+
A palindrome is a word which reads the same backward as forward, such as 'madam' or 'racecar'
4+
5+
## Install
6+
7+
```
8+
npm install allalgorithms
9+
```
10+
11+
## Usage
12+
13+
```js
14+
const allalgorithms = require('allalgorithms');
15+
16+
const str = 'racecar';
17+
18+
console.log(allalgorithms.strings.palindrome(str));
19+
// -> true
20+
```
21+
22+
## API
23+
24+
### palindrome(str)
25+
26+
> Returns true if string is palindrome
27+
28+
##### Params:
29+
30+
- `str`: String

docs/strings/reverse.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Reverse
2+
3+
Simply string reverse method, that's all :)
4+
5+
## Install
6+
7+
```
8+
npm install allalgorithms
9+
```
10+
11+
## Usage
12+
13+
```js
14+
const allalgorithms = require('allalgorithms');
15+
16+
const str = 'orange';
17+
18+
console.log(allalgorithms.strings.reverse(str));
19+
// -> egnaro
20+
```
21+
22+
## API
23+
24+
### reverse(str)
25+
26+
> Returns reversed string
27+
28+
##### Params:
29+
30+
- `str`: String

docs/strings/vowels.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Vowels
2+
3+
Method calculate vowels in word, phrase. Vowels are the characters 'a', 'e', 'i', 'o', and 'u'
4+
5+
## Install
6+
7+
```
8+
npm install allalgorithms
9+
```
10+
11+
## Usage
12+
13+
```js
14+
const allalgorithms = require('allalgorithms');
15+
16+
const str = 'How do you do?';
17+
18+
console.log(allalgorithms.strings.vowels(str));
19+
// -> 5
20+
```
21+
22+
## API
23+
24+
### vowels(str)
25+
26+
> Returns count of vowels inside string
27+
28+
##### Params:
29+
30+
- `str`: String

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
module.exports = {
2-
sorting: require('./src/sorting'),
2+
sorting: require('./src/sorting'),
3+
strings: require('./src/strings')
34
};

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy