Commit d4b10c51 authored by Kyle Muldoon's avatar Kyle Muldoon

added loops and conditional branching

parent 009ccf6d
...@@ -15,15 +15,6 @@ ...@@ -15,15 +15,6 @@
max-width: 100%; max-width: 100%;
min-width: 100px; min-width: 100px;
} }
display: block;
background: none;
white-space: pre;
-webkit-overflow-scrolling: touch;
overflow-x: scroll;
max-width: 100%;
min-width: 100px;
padding: 0;
</style> </style>
</head> </head>
<body> <body>
...@@ -137,6 +128,37 @@ ...@@ -137,6 +128,37 @@
<h4>SWITCH</h4> <h4>SWITCH</h4>
<code>
let course = "art";
switch (course) {
case "art":
document.write("draw like picasso");
break;
case "math":
document.write("solve like newton");
break;
default:
document.write("do something else");
}
</code>
<script>
let course = "art";
switch (course) {
case "art":
document.write("draw like picasso");
break;
case "math":
document.write("solve like newton");
break;
default:
document.write("do something else");
}
</script>
<hr> <hr>
</div> </div>
...@@ -144,6 +166,25 @@ ...@@ -144,6 +166,25 @@
<!-- ============================================================= --> <!-- ============================================================= -->
<div class="concept" id="loops"> <div class="concept" id="loops">
<h2>Loops</h2> <h2>Loops</h2>
<script>
numList = ['a', 'b', 'c', 'd', 'e', 'f'];
document.write('<h3>for in loop</h3>');
for (let i in numList) {document.write(i)};
document.write('<h3>for of loop</h3>');
for (let i of numList) {document.write(i)};
document.write('<h3>while loop</h3>');
pets = ['dog', 'cat', 'rabbit', 'bird', 'turtle'];
let i = 0;
while (pets[i] !== 'turtle') {
console.log('in while loop')
document.writeln(pets[i] + '<br>');
i++;
}
</script>
<hr> <hr>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment