Skip to content

Instantly share code, notes, and snippets.

@stevencombs
Created August 25, 2013 21:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevencombs/6336280 to your computer and use it in GitHub Desktop.
Save stevencombs/6336280 to your computer and use it in GitHub Desktop.
// 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