-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstring.js
More file actions
58 lines (41 loc) · 1.27 KB
/
string.js
File metadata and controls
58 lines (41 loc) · 1.27 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
const text = 'I love React and Angular.JS';
console.log(text);
console.log(text.replace('React', 'React.JS'));
// Example 2
const str = 'JS will, JS will rock you!';
console.log(str);
const newStr = str.replace(/JS/g, 'JavaScript');
console.log(newStr);
var address = "Dhormopur, Sundorgonj, Gaibandha";
console.log(address);
let name = "Mbr-Sagor";
console.log(name);
const username = "Sagor";
console.log(username);
// let language ="Bozlur ";
// let middle_name = "Rosid ";
// let last_name ="Sagor";
// console.log(language, middle_name, last_name);
let [first_name, middle_name, last_name] = ["Bozlur", "Rosid", "Sagor"];
console.log(first_name, middle_name, last_name);
var page = window.open('/path/to/pdf');
console.log(page.print());
// String validation
var myString = "An /invalid &string;";
var charList = ['/', '\\', '&', ';']; // etc...
function sanitize(input, list) {
for (char in list) {
input = input.replace(char, '');
}
return input
}
let san = sanitize();
console.log(san);
let text2 = "How are you doing today?";
const myArray = text2.split(" ");
let word = myArray[1];
console.log(word);
// string format with variables
var my_name = 'John';
var s = `hello ${my_name}, how are you doing`;
console.log(s); // prints hello John, how are you doing