-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstringAssignment.js
More file actions
91 lines (87 loc) · 1.92 KB
/
stringAssignment.js
File metadata and controls
91 lines (87 loc) · 1.92 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
let str = 'my name is khan';
let s = str.concat('my name is khan i m not a terrorist');
console.log(s);
s = str.includes('kh',4);
console.log(s);
s = str.replace('khan','anwar');
console.log(s);
s = str.search('na');
console.log(s);
s = str.trim('');
console.log(s);
s = str.substr(0,7);
console.log(s);
s = str.split(' ');
console.log(s);
// 2nd string
let str1 = 'hello world';
let a = str1.indexOf('lo');
console.log(a);
a = str1.concat('hello world bhut hard');
console.log(a);
a = str1.includes('ld',4);
console.log(a);
a = str1.replace('llo','lll');
console.log(a);
a = str1.search('ell')
console.log(a);
a = str1.substr(0,6);
console.log(a);
a = str1.split('0');
console.log(a);
// 3rd string
let str2 = 'remove codes';
let b = str2.concat(' plz');
console.log(b);
b = str2.includes('ve',3);
console.log(b);
b = str2.replace('codes','pants');
console.log(b);
b = str2.search('pants');
console.log(b);
b = str2.substr(0,7);
console.log(b);
b = str2.split('o')
console.log(b);
// 4th string
let str3 = 'dats my phone'
let c = str3.concat(' fuck off');
console.log(c);
c = str3.includes('ats',1);
console.log(c);
c = str3.replace('dats','thats');
console.log(c);
c = str3.search('my');
console.log(c);
c = str3.substr(3,9);
console.log(c);
c = str3.split('m');
console.log(c);
// 5th string
let str4 = 'bahut hard'
let d = str4.concat('emiway');
console.log(d);
d = str4.includes('hard');
console.log(d);
d = str4.replace('bahut','hard');
console.log(d);
d = str4.search('hard');
console.log(d);
d = str4.substr(0,5);
console.log(d);
d = str4.split('h')
console.log(d);
// 6th string
let str5 = 'lets talk';
let e = str5.concat(' to her');
console.log(e);
e = str5.includes('t');
console.log(e);
e = str5.replace('lets','let me');
console.log(e);
e = str5.search('t');
console.log(e);
e = str5.substr(0,4);
console.log(e);
e = str5.split('s');
console.log(e);