-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathP4.js
More file actions
41 lines (31 loc) · 1.04 KB
/
P4.js
File metadata and controls
41 lines (31 loc) · 1.04 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
//Q-1
let s = "Har\""
console.log(s.length);
//Q-2....
const sentence = "The quick brown fox jumps over the lazy dog.";
const word = "New";
// const word = "fox";
console.log(sentence.includes(word));
console.log(`The word "${word}" ${sentence.includes(word) ? "is" : "is not"} in the sentence`,);
//Q-2...
const str1 = "Saturday night plans";
console.log(str1.startsWith("Sat"));
console.log(str1.endsWith("fdans"));
//Q-3
let str = "Hii,This is My Site.."
console.log(str.toLowerCase());
console.log(str.toUpperCase());
//Q-4
let a = "please give Rs 1000"
let amount = Number.parseInt(a.slice(15))
console.log(amount);
console.log(typeof amount); // by cwh
// let text = "please give Rs1000";
// let index = text.indexOf("Rs") + 2; // Find "Rs" and move to the number
// let amount = text.slice(index); // Extract the number part
// console.log(amount); // Output: 1000
// console.log(typeof amount); - by cgpt
//Q-5
let f = "Mansi"
f[3]= "V"
console.log(f);// f is not changed. because string is immutable...