-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstring.html
More file actions
32 lines (26 loc) · 827 Bytes
/
Copy pathstring.html
File metadata and controls
32 lines (26 loc) · 827 Bytes
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
<html>
<head>
<title>string example</title>
</head>
<body>
<p>count the string length</p>
<p id='demo'></p>
<script>
var x= "Hey Hello Wrold..!"
document.getElementById('demo').innerHTML = x.length;
</script>
<p>The indexOf() method returns the position of the first occurrence of a specified text:</p>
<p id="Demo"></p>
<script>
var str = "Please locate where 'locate' occurs!";
var pos = str.indexOf("where");
document.getElementById("Demo").innerHTML = pos;
</script>
<p id="arr"></p>
<script>
var cars = ["BMW","Volvo","Honda"];
cars[2] = "Hero";
document.getElementById("arr").innerHTML = cars;
</script>
</body>
</html>