-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
updating content for string in dsa folder #124
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4023ce3
Updated loop content for DSA folder
nsundriyal62 2539ea2
adding string in javascript dsa folder
nsundriyal62 6528b18
Revert "adding string in javascript dsa folder"
nsundriyal62 1cadf6f
rewritting loops content for dsa
nsundriyal62 5ff061e
string content changed in dsa folder
nsundriyal62 70f4bae
Revert "string content changed in dsa folder"
nsundriyal62 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,148 @@ | ||
--- | ||
title: String | ||
description: Learn String in JavaScript | ||
title: Strings | ||
description: Learn Strings in JavaScript | ||
--- | ||
|
||
<Callout> | ||
Want to improve this page? Raise an issue on [@github](https://github.com/FrontendFreaks/Official-Website). | ||
</Callout> | ||
## What's on this section? | ||
|
||
In this section, you will: | ||
|
||
- 🎨 Explore different string manipulation techniques in JavaScript. | ||
- 🔍 Understand the various string methods and their usage. | ||
- 💡 Learn about template literals and string interpolation. | ||
- 🚀 Practice your knowledge through assignments related to string manipulation. | ||
|
||
<Tabs defaultValue="learn"> | ||
|
||
<TabsList> | ||
<TabsTrigger value="learn">Learn</TabsTrigger> | ||
<TabsTrigger value="assignment">Assignment</TabsTrigger> | ||
</TabsList> | ||
|
||
<TabsContent value="learn"> | ||
|
||
## 📺 Watch Now | ||
|
||
<div className="w-full h-full"> | ||
<a href="https://www.youtube.com/watch?v=Unc365YFdf4" > | ||
<img className="w-full h-full object-cover" src="https://camo.githubusercontent.com/266a84400260b3b6aa0d97332a19d301ee8f767d229083dfd58931781efea309/68747470733a2f2f696d672e796f75747562652e636f6d2f76692f556e6333363559466466342f302e6a7067" alt="JavaScript Loops" /> | ||
</a> | ||
</div> | ||
|
||
<Callout type="info"> | ||
We hope that you found the tutorial video helpful in understanding the basic concepts of Strings in java, You can refer this notes 📝 for quick revision. | ||
</Callout> | ||
|
||
## 📝 Study Notes | ||
|
||
# String In JavaScript | ||
|
||
|
||
### Length of a String | ||
```javascript | ||
let firstName = "Vaishali"; | ||
console.log(firstName.length); | ||
``` | ||
|
||
### Access String Element | ||
```javascript | ||
console.log(firstName.charAt(2)); // i | ||
console.log(firstName[2]); // i | ||
console.log(firstName.charCodeAt(2)); // 115 (Ascii Code) | ||
``` | ||
|
||
### Check Presence of Character | ||
```javascript | ||
console.log(firstName.includes("r")); // false (& if present it return true) | ||
console.log(firstName.indexOf("i")); // 2 (& if not present it return -1) | ||
console.log(firstName.lastIndexOf("i")); // 7 | ||
``` | ||
|
||
### Compare Two Strings | ||
```javascript | ||
let anotherName = "Vishal"; | ||
console.log(firstName.localeCompare(anotherName)); // -1 (& if strings are equal it return 0) | ||
``` | ||
|
||
### Replace Substring | ||
```javascript | ||
const str = "Vishal is Best Frontend Developer. Vishal is Best Developer. "; | ||
console.log(str.replace("Vishal", "Sujit")); // "Sujit is Best Frontend Developer. Vishal is Best Developer. " | ||
console.log(str.replaceAll("Vishal", "Sujit")); // "Sujit is Best Frontend Developer. Sujit is Best Developer. " | ||
``` | ||
|
||
### Substring of a String | ||
```javascript | ||
console.log(str.substring(6, 30)); | ||
console.log(str.slice(-10, -1)); | ||
``` | ||
|
||
### Split and Join | ||
```javascript | ||
console.log(str.split("")); | ||
const subString = str.split(" "); | ||
console.log(subString.join(" ")); | ||
``` | ||
|
||
### String Start and End | ||
```javascript | ||
console.log(str.startsWith("Vishal")); // true | ||
console.log(str.endsWith("Developer")); // true | ||
``` | ||
|
||
### Trim and Case Conversion | ||
```javascript | ||
const trimStr = str.trim(); | ||
const trimStrStart = str.trimStart(); | ||
const trimStrEnd = str.trimEnd(); | ||
console.log(trimStr, trimStr.length); | ||
console.log(str.toLowerCase()); | ||
console.log(str.toUpperCase()); | ||
``` | ||
|
||
### Convert Number and Object to String | ||
```javascript | ||
const num = 123; | ||
console.log(num, num.toString()); | ||
|
||
const obj = { | ||
name: "Vishal", | ||
course: "DSA with Vishal" | ||
}; | ||
console.log(obj, JSON.stringify(obj)); | ||
``` | ||
|
||
### Concatenate Strings | ||
```javascript | ||
const lastName = "Rajput"; | ||
console.log(firstName + lastName); | ||
console.log(`${firstName} ${lastName} is a Best Developer`); | ||
console.log(firstName.concat(lastName, " is a", " Best")); | ||
``` | ||
|
||
|
||
</TabsContent> | ||
|
||
<TabsContent value="assignment"> | ||
## Practice Questions | ||
|
||
- [Find the Index of the First Occurrence in a String](https://leetcode.com/problems/find-the-index-of-the-first-occurrence-in-a-string/) | ||
- [Reverse String](https://leetcode.com/problems/reverse-string) | ||
- [Valid Anagram](https://leetcode.com/problems/valid-anagram) | ||
- [Longest Common Prefix](https://leetcode.com/problems/longest-common-prefix) | ||
- [Merge Strings Alternately](https://leetcode.com/problems/merge-strings-alternately) | ||
- [Length of Last Word](https://leetcode.com/problems/length-of-last-word/) | ||
- [Valid Palindrome](https://leetcode.com/problems/valid-palindrome) | ||
- [String Compression](https://leetcode.com/problems/string-compression) | ||
- [Reverse Words in a String](https://leetcode.com/problems/reverse-words-in-a-string) | ||
- [Reverse Vowels of a String](https://leetcode.com/problems/reverse-vowels-of-a-string) | ||
- [Rotate String](https://leetcode.com/problems/rotate-string) | ||
|
||
</TabsContent> | ||
|
||
|
||
</Tabs> | ||
|
||
Want to improve this page?. Raise a issue on [@github](https://github.com/FrontendFreaks/Official-Website). | ||
</Callout> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the src you have to add youtube video id, which is
Unc365YFdf4
in this case.http://img.youtube.com/vi/{YouTube_id}/0.jpg
so img tag will be like this
<img className="w-full h-full object-cover" src="http://img.youtube.com/vi/Unc365YFdf4/0.jpg" alt="Strings in JavaScript" />