-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstringmethodsCopy.js
More file actions
111 lines (76 loc) · 2.74 KB
/
stringmethodsCopy.js
File metadata and controls
111 lines (76 loc) · 2.74 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
//String concatenation//
//concatenate (or join) two or more strings using the concatenation operator, +. //
let x= 'When candles are out,';
let y= 'all cats are grey.';
let z= x + ' ' + y;
console.log(z);
let text = "Hello world, welcome to the universe";
let result = text.includes("world")
console.log(result) // includes () method
let text1 = "Hello world, welcome to the universe";
let result1 = text1.includes("world", 12)
console.log(result1)
let str ="java script is great" ;
console.log('includes',str.includes("extend"))
console.log('length',str.length)
console.log('charAt',str.charAt(5))
console.log('charCodeAt',str.charCodeAt(0))
console.log('concat',str = str.concat('. Now iam learning it, it is interesting.'))
console.log('endsWith',str.endsWith('it'));
console.log('includes 2',str.includes('interesting'))
console.log('indexOf',str.indexOf('great'))
console.log('lastIndexOf',str.lastIndexOf('is'))
// ===
console.log('===', '111' === 111);
console.log('==', '111' == 111);
console.log('typeof', typeof('111'));
console.log(`template literal ${'111' == 111}`)
console.log('includes',str.includes("extend"))
console.log(`includes ${str.includes("extend")}`)
//template literals//
console.log(`includes ${str.includes("extend")}`)
console.log('$length',str.length)
console.log('$charAt',str.charAt(5))
console.log('$charCodeAt',str.charCodeAt(0))
console.log('$concat',str = str.concat('. Now iam learning it, it is interesting.'))
console.log('$endsWith',str.endsWith('it'));
console.log('$includes 2',str.includes('interesting'))
console.log('$indexOf',str.indexOf('great'))
console.log('$lastIndexOf',str.lastIndexOf('is'))
// ===
console.log('$===', '111' === 111);
console.log('$==', '111' == 111);
console.log('$typeof', typeof('111'));
console.log(`$template literal ${'111' == 111}`)
console.log('$includes',str.includes("extend"))
console.log(`$includes ${str.includes("extend")}`)
/**
*
* 1)re write all of the above statemnets using template literals
*
* 2) c onst stringArr = ['Bhavani-Developer', 'Ram-Developer', 'Bhanu-Devops', 'Madhavi-QA'];
*
* iterate through the array and printout the people who are developers
*
* print the count of the developers
*
*
*
*
*
*/
const stringArr = ['Bhavani-Developer', 'Ram-Developer', 'Bhanu-Devops', 'Madhavi-QA'];
let count = 0;
for(let i=0;i<stringArr.length;i++){
// if condition
if(stringArr[i].includes('Developer')){
const names = stringArr[i].split('-')
//console.log('names')
//const stringArr1 =stringArr.split ('')//
// break it with - split()//
// store the result in names
console.log(names[0])
count = count + 1;
}
}
console.log('number of developers', count);