-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuestion3.html
More file actions
48 lines (34 loc) · 1.18 KB
/
Question3.html
File metadata and controls
48 lines (34 loc) · 1.18 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Question 3</title>
</head>
<body>
<bold id="lower"></bold><br>
<bold id="upper"></bold><br>
<bold id="title"></bold><br>
</body>
<script>
var name = prompt("Please enter your name:");
var lname = name.toLowerCase();
var uname = name.toUpperCase();
var tcase = name.split(" ");
document.getElementById('lower').innerHTML = "Name in LowerCase: " + lname;
document.getElementById('upper').innerHTML = "Name in UpperCase: " + uname;
let i = 0;
var string = '';
while(i <= tcase.length){
try {
let temp = tcase[i].toLowerCase();
string = string + ' ' + temp.replace(temp.slice(0,1), temp.slice(0,1).toUpperCase());
} catch (error) {
console.log(error);
}
i++;
}
document.getElementById('title').innerHTML = "Name in TitleCase: " + string;
</script>
</html>