-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstring-methods.js
More file actions
72 lines (41 loc) · 1.12 KB
/
string-methods.js
File metadata and controls
72 lines (41 loc) · 1.12 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
56
57
58
59
60
61
62
63
64
65
66
67
var string1 = "Today we will learn javascript"
var string2 = "We will also have some food & food"
//charAt()
console.log(string1.charAt(3))
//concat()
console.log(string1.concat(string2))
//endsWith()
console.log(string1.endsWith("javascript"))
//fromCharCode()
console.log(String.fromCharCode(117))
//charCodeAt()
console.log(string1.charCodeAt(3))
//includes()
console.log(string1.includes("food"))
//lastIndexOf()
console.log(string2.lastIndexOf("food"))
//match
console.log(string2.match("/food/g"))
//indexOf
console.log(string2.indexOf("food"))
//repeat
console.log(string2.indexOf("5"))
//slice()
console.log(string2.slice(2,4))
//replace()
console.log(string2.match("/food/g","Food"))
//search
console.log(string2.search("food"))
//split()
console.log(string2.split(" "))
//substr()
console.log(strign2.substr(2,4)) //this will extract the string from 2 to 4
//substring()
console.log(strign2.substring(2,4)) //like slice
//toLowerCase()
console.log(strign1.toLowerCase())
//toUpperCase()
console.log(strign1.toUpperCase())
//trim()
var string3 = " My name is Manjula"
console.log(strign1.trim())