-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlab5_exe_B.html
More file actions
37 lines (32 loc) · 1.09 KB
/
lab5_exe_B.html
File metadata and controls
37 lines (32 loc) · 1.09 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JavaScript String and Variable Exercise</title>
</head>
<body>
<!-- Content goes here -->
<script>
// Declare Variables
let firstName = "Jindjeet";
let lastName = "Cheema";
let age = 20;
// Concatenate Strings
let fullName = firstName + " " + lastName;
console.log(fullName);
// Calculate Birth Year
let currentYear = new Date().getFullYear();
let birthYear = currentYear - age;
console.log(birthYear);
// String Manipulation
console.log(fullName.length);
console.log(fullName.toUpperCase());
// Template Literals
console.log(`Hello, my name is ${fullName} and I am ${age} years old. I was born in ${birthYear}.`);
// Bonus: Conditional Operator
let canVote = age > 18 ? true : false;
console.log(`I am eligible to vote: ${canVote}`);
</script>
</body>
</html>