-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path06_strings.js
More file actions
55 lines (34 loc) · 1.33 KB
/
06_strings.js
File metadata and controls
55 lines (34 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const name = "Rishav"
const repoCount = 20
// console.log(name + repoCount + " Value") // older method
//newer method
console.log(`Hello my name is ${name} and my repo count is ${repoCount} `)
// another way to take input in strings
// these also provides us with the in built function of strings
const game = new String('valorant-hox-purity-pixels')
console.log(game[0]);
//gives the length of the letter
console.log(game.length);
//make the total letter into capitalize format
console.log(game.toUpperCase());
//give the character at the index given
console.log(game.charAt(3));
// Gives the index at which n is present in the word
console.log(game.indexOf('n'));
//slice the word only but not the reverse part
const newName = game.substring(0,4);
console.log(newName)
//slice the word from the reverse also and normal also
const anotherName = game.slice(-8,-2)
console.log(anotherName)
//Trims the extra spaces present
const newString = " Rishav "
console.log(newString)
console.log(newString.trim())
// replaces the desired element
const url = "https://rishav.com/rishav%20"
console.log(url.replace('%20' , '-'))
// check whether it's present or not
console.log(url.includes("risv"))
// seprates or split the name into which they are sub-divided
console.log(game.split('-'))