mirror of
https://github.com/Nezumi-2711/javascript-training.git
synced 2026-09-22 20:01:31 +00:00
Init strings and conditionals sample
This commit is contained in:
@@ -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>
|
||||
@@ -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);
|
||||
Reference in New Issue
Block a user