-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQ3.ts
24 lines (16 loc) · 797 Bytes
/
Q3.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Q2: Name Cases: Store a person’s name in a variable, and then print that person’s name in lowercase, uppercase, and titlecase.
function q3(){
let name: string = "tech";
console.log(`Lowercase: ${name.toLowerCase()}`);
console.log(`Uppercase: ${name.toUpperCase()}`);
console.log(`Titlecase: ${name.charAt(0).toUpperCase() + name.slice(1)}`);
let sentence: string = "Hello i am abdul hannan";
let words: string[] = sentence.split(" ");
let titleCaseWords: string[] = words.map(function(word) {
return word[0].toUpperCase() + word.slice(1).toLowerCase();
});
let titleCaseSentence: string = titleCaseWords.join(" ");
console.log(titleCaseSentence);
}
q3();
export default q3;