-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlec6.html
More file actions
105 lines (75 loc) · 2.46 KB
/
lec6.html
File metadata and controls
105 lines (75 loc) · 2.46 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
105
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
// let str="JavaScript is Awesome!";
// console.log("original String: '"+str+"'");
// // 1. length
// console.log("Length:",str.length);//includes spaces
// // 2. trim
// console.log("trimmed",str.trim());//removes space
// // 3. toUpperCase
// console.log(str.toUpperCase());
// // 4.toLowerCase
// console.log(str.toLowerCase());
// // 5.includes
// console.log("Includes Awesome:",str.includes("Awesome"));
// // 6.startsWith
// console.log(str.startsWith(" Java"));
// // 7. endsWith
// console.log(str.endsWith("! "));
// // 8. indexOf
// console.log(str.indexOf("is"));
// // 9. lastIndexOf
// console.log(str.lastIndexOf("a"));
// // 10. charAt
// console.log("Character at index 5",str.charAt(5));
// // 11. substring(from index 2 to 10)
// console.log(str.substring(2,10));
// // 12. slice
// console.log("Slice (2,-1):",str.slice(2,-1));
// // 13. spilit
// console.log("split by space:",str.trim().split(" "));
// // 14. replace
// console.log(str.replace("Awesome","Powerful"));
// // 15. repeat
// console.log("Repeat 3 times:","JS".repeat(3));
// console.log(str.repeat(3));
// let str="aaabbbbcccc" //a3b4c4
// let newStr=""
// let count=1;
// for(let i=0;i<str.length;i++){
// if(str[i]==str[i+1]){
// count++;
// }
// else{
// newStr+=str[i]+count;
// count=1
// }
// }
// console.log(newStr);
// let str="aaabbbbccccaa"
// let newStr=""
// // let count=1;
// for(let i=0;i<str.length;i++){
// if(!newStr.includes(str[i])){
// newStr+=str[i]
// }
// }
// console.log(newStr);
let arr=[1,2,3,4,5,6];
let arr1=[1,2,3,7,8];
let arr2=[];
for(let i=0;i<arr.length;i++){
if((arr[i]).includes(arr1[i])){
arr2+=arr
}}
console.log(arr2);
</script>
</body>
</html>