Init strings and conditionals sample

This commit is contained in:
2023-08-07 17:00:51 +07:00
parent 953456fe4a
commit b03e6f62f0
2 changed files with 56 additions and 0 deletions
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Javascript Training</title>
</head>
<body>
<h1>Javascript Training</h1>
<script src="./index.js"></script>
</body>
</html>
+44
View File
@@ -0,0 +1,44 @@
// Strings and Template Literals
const fullName = "Nezumi";
const job = "Grab Bike";
const birthYear = 2001;
const year = 2023;
const nezumi =
"I'm " + fullName + ", a " + (year - birthYear) + " year old " + job + "!";
console.log(nezumi);
const nezumiNew = `I'm ${fullName}, a ${year - birthYear} year old ${job}!`;
console.log(nezumiNew);
console.log(`Hello World!`);
console.log(
"String with \n\
multiple \n\
lines"
);
console.log(`String
multiple
lines`);
// if / else Statements
const age = 15;
if (age >= 18) {
console.log("Nezumi is over 18 years!");
} else {
const yearsLeft = 18 - age;
console.log(`Nezumi is to young. Waiting more ${yearsLeft} years.`);
}
const mark = 10;
let classification;
if (mark === 10) {
classification = "Excellent";
} else {
classification = "Good";
}
console.log(classification);