-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchap4.js
More file actions
77 lines (64 loc) · 1.75 KB
/
chap4.js
File metadata and controls
77 lines (64 loc) · 1.75 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
//Strings- a combination of characters and used to store the data
/*
//store string
let s1="madhav";
let s2='madhav';
let s3=`madhav`;
console.log(s1,s2,s3);
//iterate each symbol
for(let i=0;i<s3.length;i++)
{
console.log(s1[i]);
}
//print any particular symbol
console.log(s1[2]);
*/
//combine lines in to a paragraph :- use forward slash (\)
/*
let s4="Hi, I am \
madhav, studying in MCA \
in UTU Dehradun"
console.log(s4);
*/
//Add two or more strings
/*
let fname="Madhav";
let sname="Gupta";
//1. Using '+' :- gives unexpected result so don't use it
let fullname=fname + sname;
console.log(fullname);
//2. Using concating ($)
let fullname=`${fname}${sname}`; // to use "${variable_name}" use backtick (``) outside of using variable
console.log(fullname);
//Extra (fetching strings)
let age=21;
let intro=`My name is :- ${fname} ${sname} and my age is ${age}.`
console.log(intro);
*/
//Changing cases
/*
let fullname="Madhav Gupta";
//Uppercase
console.log(fullname.toUpperCase());
//Lowercase
console.log(fullname.toLowerCase());
*/
//Find a keyword in an paragraph
/*
let intro="Hi, I am madhav, studying in MCA in UTU Dehradun.";
let keyWord="UTU";
console.log(intro.search(keyWord)); //return the index no. of first character
//Replace any word
let replaceWord="VMSBUTU";
console.log(intro.replace(keyWord,replaceWord));
*/
//Substr, substring, slice
/*
let intro="Hi, I am madhav, studying in MCA in UTU Dehradun.";
//slice
let partIntro=intro.slice(0,31); //same as array
console.log(partIntro+" ...read more");
//substring
let subIntro=intro.substring(0); //1 value- leave index from start and print remaining, 2 values- leave index equal to 1st val and print next index as 2nd val, 0 in function then retrun whole string
console.log(subIntro);
*/