Last active
April 25, 2018 19:34
-
-
Save stormsweeper/2f5418ddf26f15b2c6ae1bdb9d07c470 to your computer and use it in GitHub Desktop.
Exported from Popcode. Click to import: https://popcode.org/?gist=2f5418ddf26f15b2c6ae1bdb9d07c470
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Exercises With Arrays And For Loops</title> | |
</head> | |
<body> | |
<h1>Exercises With Arrays And For Loops</h1> | |
<div id="exercise01" class="exercise"> | |
<h3>Exercise #01</h3> | |
<div class="answer"> | |
</div> | |
</div> | |
<div id="exercise02" class="exercise"> | |
<h3>Exercise #02</h3> | |
<div class="answer"> | |
</div> | |
</div> | |
<div id="exercise03" class="exercise"> | |
<h3>Exercise #03</h3> | |
<div class="answer"> | |
</div> | |
</div> | |
<div id="exercise04" class="exercise"> | |
<h3>Exercise #04</h3> | |
<div class="answer"> | |
</div> | |
</div> | |
<div id="exercise05" class="exercise"> | |
<h3>Exercise #05</h3> | |
<div class="answer"> | |
</div> | |
</div> | |
<div id="exercise06" class="exercise"> | |
<h3>Exercise #06</h3> | |
<div class="answer"> | |
</div> | |
</div> | |
<div id="exercise07" class="exercise"> | |
<h3>Exercise #07</h3> | |
<div class="answer"> | |
</div> | |
<div class="output" id="output07"> | |
</div> | |
</div> | |
<div id="exercise08" class="exercise"> | |
<h3>Exercise #08</h3> | |
<div class="answer"> | |
</div> | |
<div class="output" id="output08"> | |
</div> | |
</div> | |
<div id="exercise09" class="exercise"> | |
<h3>Exercise #09</h3> | |
<div class="answer"> | |
</div> | |
<div class="output" id="output09"> | |
</div> | |
</div> | |
<div id="exercise10" class="exercise"> | |
<h3>Exercise #10</h3> | |
<div class="answer"> | |
</div> | |
<div class="output" id="output10"> | |
</div> | |
</div> | |
<div id="exercise11" class="exercise"> | |
<h3>Exercise #11</h3> | |
<div class="answer"> | |
</div> | |
<div class="output" id="output11"> | |
</div> | |
</div> | |
<div id="exercise12" class="exercise"> | |
<h3>Exercise #12 (BONUS)</h3> | |
<div class="answer"> | |
</div> | |
</div> | |
</body> | |
<script defer src="https://rawgit.com/stormsweeper/012953669c0d3225037d2572038d4d18/raw/524c0878a951d75817eb6ccf622ad3fba49c97ed/unit10checker.js"></script> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"enabledLibraries":["jquery"],"hiddenUIComponents":["editor.css","console"]} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Exercise #1: An empty array | |
In the function below, set the value of 'arr1' to be an empty array. | |
*/ | |
function exercise01() { | |
var arr1; | |
return arr1; | |
} | |
/* | |
Exercise #2: A not-empty array | |
In the function below, set the value of 'arr2' to be an array with 3 elements. | |
*/ | |
function exercise02() { | |
var arr2; | |
return arr2; | |
} | |
/* | |
Exercise #3: The length of an array | |
In the function below, set the value of 'length' to be the length of arr3. | |
*/ | |
function exercise03(arr3) { | |
var length; | |
return length; | |
} | |
/* | |
Exercise #4: Comparing array lengths | |
In the function below, set the value of 'aEqualsB' to true if the length of | |
a is equal to the length of b. | |
*/ | |
function exercise04(a, b) { | |
var aEqualsB; | |
return aEqualsB; | |
} | |
/* | |
Exercise #5: Comparing array lengths again | |
In the function below, set the value of 'aGreaterThanB' to true if the length of | |
a is greater than the length of b. | |
*/ | |
function exercise05(a, b) { | |
var aGreaterThanB; | |
return aGreaterThanB; | |
} | |
/* | |
Exercise #6: Adding to an array | |
In the function below, add your name to the end of arr6. | |
*/ | |
function exercise06(arr6) { | |
// your code here | |
} | |
/* | |
Exercise #7: For loops - counting up | |
In the function below, create a for loop that runs from 0 to 5, appending | |
that number to the div with the id 'output07'. | |
*/ | |
function exercise07() { | |
// your code here | |
} | |
/* | |
Exercise #8: For loops - counting down | |
In the function below, create a for loop that counts from 10 to 1, appending | |
that number to the div with the id 'output08'. | |
*/ | |
function exercise08() { | |
// your code here | |
} | |
/* | |
Exercise #9: For loops - only even numbers | |
In the function below, create a for loop that counts from 1 to 20, appending | |
only the even numbers to the div with the id 'output09'. | |
*/ | |
function exercise09() { | |
// your code here | |
} | |
/* | |
Exercise #10: For loops - with an array | |
In the function below, create a for loop that appends each element in 'arr10' | |
to the div with the id 'output10'. The output will be a greeting. | |
*/ | |
function exercise10(arr10) { | |
// your code here | |
} | |
/* | |
Exercise #11: For loops - One loop, two arrays | |
In the function below, create a for loop that appends each element in 'arrA' | |
and 'arrB' to the div with the id 'output11'. The output will be a secret message. | |
Example: if arrA is ["H", "l", "o"] and arrB is ["e", "l", "!"], the final | |
output would be "Hello!" | |
Note: 'arrA' and 'arrB' are the same length | |
*/ | |
function exercise11(arrA, arrB) { | |
// your code here | |
} | |
/* | |
BONUS Exercise #12: For loops - One loop, two arrays | |
In the function below, create a for loop that adds elements in 'arrA' | |
to 'arrB' if they are greater than 5. | |
Example: if arrA is [1, 3, 5, 7, 9], you should add 7 and 9 to arrB | |
*/ | |
function exercise12(arrA, arrB) { | |
// your code here | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
background-color: #056839; | |
font-family: sans-serif; | |
} | |
.exercise { | |
margin: 10px 5px; | |
padding: 2px 5px; | |
background: white; | |
} | |
.exercise .answer { | |
border: 1px solid #056839; | |
padding: 4px; | |
margin: 2px; | |
} | |
.exercise .output { | |
padding: 4px; | |
margin: 2px; | |
background: #eee; | |
font-family: monospace; | |
} | |
.exercise .answer.incorrect { | |
color: #c00; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment