-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringFunction.html
More file actions
33 lines (31 loc) · 1003 Bytes
/
StringFunction.html
File metadata and controls
33 lines (31 loc) · 1003 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
33
<!DOCTYPE html>
<html lang="en">
<head>
<title>JavaScript String Functions</title>
<style>
</style>
</head>
<body>
<script>
var str = "this is string";
console.log(str);
var position = str.indexOf('is');
console.log(position);
position = str.lastIndexOf('is')
console.log(position)
var substr = str.slice(-1,5);
console.log(substr)
var substr = str.substring(-1,5);
console.log(substr)
var substr = str.substr(1,5);
console.log(substr)
var replaced = str.replace('string', 'varsha')
console.log(replaced)
console.log(str.toUpperCase())
console.log(str.toLowerCase())
var spaces = " this contains whitespaces";
console.log(spaces);
console.log(spaces.trim())
</script>
</body>
</html>