Skip to content

Commit 0aa9ebe

Browse files
committed
added String Video link
1 parent 4be3465 commit 0aa9ebe

File tree

2 files changed

+57
-28
lines changed

2 files changed

+57
-28
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@
2525
- [Loops in JavaScript](https://github.com/Vishal-raj-1/DSA-In-JS-With-Vishal/blob/main/Basics/README.md)
2626
- [Time Complexity: Big O notation](https://github.com/Vishal-raj-1/DSA-In-JS-With-Vishal/blob/main/Time%20Complexity/README.md)
2727
- [Array](https://github.com/Vishal-raj-1/DSA-In-JS-With-Vishal/blob/main/Array/README.md)
28-
- [Polyfill of Map, Filter & Reduce](https://github.com/Vishal-raj-1/DSA-In-JS-With-Vishal/blob/main/Array/Polyfill.md)
28+
- [Polyfill of Map, Filter & Reduce](https://github.com/Vishal-raj-1/DSA-In-JS-With-Vishal/blob/main/Array/Polyfill.md)
29+
- [String](https://github.com/Vishal-raj-1/DSA-In-JS-With-Vishal/blob/main/String/README.md)

String/README.md

Lines changed: 55 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,91 @@
1-
# String Methods in JavaScript
1+
# String In JavaScript
22

3-
### charAt()
4-
```javascript
5-
const charAtIndex = "Hello".charAt(1); // Output: "e"
6-
```
3+
<p align="center">
4+
<a href="https://youtube.com/live/Unc365YFdf4">
5+
<img src="https://img.youtube.com/vi/Unc365YFdf4/0.jpg" alt="String In JavaScript" />
6+
</a>
7+
</p>
78

8-
### concat()
9+
### Length of a String
910
```javascript
10-
const concatenated = "Hello".concat(" World"); // Output: "Hello World"
11+
let firstName = "Vaishali";
12+
console.log(firstName.length);
1113
```
1214

13-
### toUpperCase()
15+
### Access String Element
1416
```javascript
15-
const upperCaseString = "hello".toUpperCase(); // Output: "HELLO"
17+
console.log(firstName.charAt(2)); // i
18+
console.log(firstName[2]); // i
19+
console.log(firstName.charCodeAt(2)); // 115 (Ascii Code)
1620
```
1721

18-
### toLowerCase()
22+
### Check Presence of Character
1923
```javascript
20-
const lowerCaseString = "HeLLo".toLowerCase(); // Output: "hello"
24+
console.log(firstName.includes("r")); // false (& if present it return true)
25+
console.log(firstName.indexOf("i")); // 2 (& if not present it return -1)
26+
console.log(firstName.lastIndexOf("i")); // 7
2127
```
2228

23-
### substring()
29+
### Compare Two Strings
2430
```javascript
25-
const subString = "JavaScript".substring(4, 10); // Output: "Script"
31+
let anotherName = "Vishal";
32+
console.log(firstName.localeCompare(anotherName)); // -1 (& if strings are equal it return 0)
2633
```
2734

28-
### replace()
35+
### Replace Substring
2936
```javascript
30-
const replacedString = "Hello, name!".replace("name", "John"); // Output: "Hello, John!"
37+
const str = "Vishal is Best Frontend Developer. Vishal is Best Developer. ";
38+
console.log(str.replace("Vishal", "Sujit")); // "Sujit is Best Frontend Developer. Vishal is Best Developer. "
39+
console.log(str.replaceAll("Vishal", "Sujit")); // "Sujit is Best Frontend Developer. Sujit is Best Developer. "
3140
```
3241

33-
### split()
42+
### Substring of a String
3443
```javascript
35-
const splitArray = "apple,banana,grape".split(","); // Output: ["apple", "banana", "grape"]
44+
console.log(str.substring(6, 30));
45+
console.log(str.slice(-10, -1));
3646
```
3747

38-
### indexOf()
48+
### Split and Join
3949
```javascript
40-
const index = "JavaScript".indexOf("Script"); // Output: 4
50+
console.log(str.split(""));
51+
const subString = str.split(" ");
52+
console.log(subString.join(" "));
4153
```
4254

43-
### endsWith()
55+
### String Start and End
4456
```javascript
45-
const endsWithWorld = "Hello, world".endsWith("world"); // Output: true
57+
console.log(str.startsWith("Vishal")); // true
58+
console.log(str.endsWith("Developer")); // true
4659
```
4760

48-
### startsWith()
61+
### Trim and Case Conversion
4962
```javascript
50-
const startsWithHello = "Hello, world".startsWith("Hello"); // Output: true
63+
const trimStr = str.trim();
64+
const trimStrStart = str.trimStart();
65+
const trimStrEnd = str.trimEnd();
66+
console.log(trimStr, trimStr.length);
67+
console.log(str.toLowerCase());
68+
console.log(str.toUpperCase());
5169
```
5270

53-
### includes()
71+
### Convert Number and Object to String
5472
```javascript
55-
const includesWorld = "Hello, world".includes("world"); // Output: true
73+
const num = 123;
74+
console.log(num, num.toString());
75+
76+
const obj = {
77+
name: "Vishal",
78+
course: "DSA with Vishal"
79+
};
80+
console.log(obj, JSON.stringify(obj));
5681
```
5782

58-
### trim()
83+
### Concatenate Strings
5984
```javascript
60-
const trimmedString = " Hello, world ".trim(); // Output: "Hello, world"
85+
const lastName = "Rajput";
86+
console.log(firstName + lastName);
87+
console.log(`${firstName} ${lastName} is a Best Developer`);
88+
console.log(firstName.concat(lastName, " is a", " Best"));
6189
```
6290

6391
## Practice Questions

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