-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstrings.html
More file actions
104 lines (72 loc) · 2.32 KB
/
strings.html
File metadata and controls
104 lines (72 loc) · 2.32 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
92
93
94
95
96
97
98
99
100
101
102
103
104
<!-- Length Property -->
<script>
let name="ROLEX";
document.write(name.length);
// output: 5
</script>
<!-- String Interpolation : Means inserting variables inside Template Literals($``)-->
<script>
const name=prompt("Enter Your Name!");
let a=`Your name is ${name}`;
document.write(a);
</script>
<!-- toUpperCase Property -->
<script>
let name=prompt("enter Your Name!");
document.write("Your Entered Name will be displayed in Upper Case now "+name.toUpperCase());
</script>
<!-- Slice Property -->
<script>
let name="DILLI";
let v=name.slice(2,4); //means from 2 to 4 and 4 is not included
document.write(v);
</script>
<!-- Slice Property 2 -->
<script>
let name="BHARGAV SANDANALA";
let slicedName=name.slice(8,17);
document.write(slicedName);
// output:SANDANALA
</script>
<!-- Replace Property -->
<script>
let agents="Dilli Amar";
let boss=agents.replace("Amar","Bejoy");
document.write(boss);
// output:Dilli Bejoy
</script>
<!-- Concat Property -->
<script>
let agent1="DILLI";
let agent2="AMAR";
let joinedHands=agent1.concat(" teamed with ",agent2," For real !!");
document.write(joinedHands);
// output:DILLI teamed with AMAR For real !!
</script>
<!-- Trim Property ~ Trims End spaces-->
<script>
let pow=" LASERSIGHT ";
document.write(pow.trim());
// output:LASERSIGHT
</script>
<!-- Includes Property -->
<script>
let name="Hello World this Robo memory 1 Gigabyte Speed 1 TerraByte";
let testing=name.includes("Gigabyte");//if you give gigabyte then o/p will be False
document.write(testing);
// output:True
</script>
<!-- startsWith Property -->
<script>
let name="Hello World this Robo memory 1 Gigabyte Speed 1 ZetaByte";
let result=name.startsWith("ZetaByte",48);
document.write(result);
// output:true
</script>
<!-- endsWith Property -->
<script>
let name="Hello World this Robo memory 1 Gigabyte Speed 1 ZetaByte";
let result=name.endsWith("ZetaByte",56);//although it's ending with corrsponding 55 int but we have to specify it as 56 bcz at the end there's a string terminator which is present (/0);
document.write(result);
// output:true
</script>