Created
May 27, 2016 11:25
-
-
Save jimnarey/d54ff38e5bcb78073dcea3609db5ed27 to your computer and use it in GitHub Desktop.
jsloop.html
This file contains 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 lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>LoopTest</title> | |
<script> | |
var year = 2014; | |
var month = 1; | |
var days = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; | |
var evenTotal = 0; | |
var oddTotal = 0; | |
var bothTotal = 0; | |
while (year <= 2016) { | |
console.log('Start year loop' + ' - ' + year); | |
while (month <= 12) { | |
console.log('Start month loop' + ' - ' + year + ' - ' + month); | |
for (let i = 0; i < days, i;) { | |
if (days[i] % 2 == 0) { | |
console.log('Even'); | |
evenTotal++; | |
} else { | |
console.log('Odd'); | |
oddTotal++; | |
} | |
bothTotal++; | |
} | |
month++; | |
} | |
month = 1; | |
year++; | |
console.log('Even total: ' + evenTotal); | |
console.log('Odd total: ' + oddTotal); | |
console.log('Both total: ' + bothTotal); | |
} | |
</script> | |
</head> | |
<body> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment