-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstring-methods.js
More file actions
40 lines (31 loc) · 881 Bytes
/
string-methods.js
File metadata and controls
40 lines (31 loc) · 881 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
34
35
36
37
38
39
40
let string = "JavaScript";
console.log("Length of string is ", string.length);
//toLowerCase()
let lowerCaseString = string.toLowerCase();
console.log(lowerCaseString);
//toUpperCase()
let upperCaseString = string.toUpperCase();
console.log(upperCaseString);
//indexOf
let position = string.indexOf("S");
console.log(position);
//substring()
let substring = string.substring(4, 10);
console.log(substring);
//split()
let strArr = string.split("");
console.log(strArr);
//replace()
let replaceString = string.replace("Script", "8");
console.log(replaceString);
//trim()
let nameTwo = " Java Script ";
console.log(nameTwo);
//concat()
let string2 = "Framework";
console.log(string.concat(string2));
//to string
let mobileNo = 9876543210;
console.log(typeof mobileNo);
console.log(mobileNo.toString());
console.log(typeof mobileNo);