Created
August 25, 2013 21:00
-
-
Save stevencombs/6336280 to your computer and use it in GitHub Desktop.
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
// Javascript Getting Started with Programming | |
// A Codecademy Javascript (Loops and Arrays III) assignment | |
// Dr. Steven B. Combs, coding novice | |
// Assign array and variable | |
var array = [3, 6, 2, 56, 32, 5, 89, 32]; | |
var largest = 0; | |
for (var i = 0; i < array.length; i++){ // Parse through array a single value at a time | |
if (array[i] > largest) { // Determine if the array element is larger than the last | |
largest = array[i]; // Assign the larger element of the array to the variable | |
} | |
} | |
console.log(largest); // Print the largest |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment