Init loops sample

This commit is contained in:
2023-08-08 16:24:00 +07:00
parent 6513cbd426
commit 9894a57b1a
2 changed files with 31 additions and 0 deletions
+12
View File
@@ -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>
+19
View File
@@ -0,0 +1,19 @@
const info = ["Nezumi", 12, "student", ["Khue", "Huy", "Dat"], true];
let i = 0;
// While loops
while (i < info.length) {
console.log(info[i]);
i++;
}
// For loops
console.log("---For loops---");
for (let index = info.length - 1; index >= 0; index--) {
console.log(i, info[index]);
}
// For...of loops
console.log("---For ... of loops---");
for (const value of info) {
console.log(value);
}