Last active
September 23, 2015 10:51
-
-
Save kosalvann/97a84337c3538f854b3e to your computer and use it in GitHub Desktop.
Define a function findLargestNumber() that takes an argument from a list of numbers as and returns the largest of them. Use the if condition to get the largest number from the list.
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
// Define a function findLargestNumber() that takes an argument | |
// from a list of numbers as and returns the largest of them. | |
// Use the if condition to get the largest number from the list. | |
// https://jsfiddle.net/3v3LoLrp/ | |
function findLargestNumber(numbers){ | |
var largestNum = 0 ; | |
for (var i = 0; i <= numbers.length; i++){ | |
if (numbers[i] > largestNum){ | |
largestNum = numbers[i]; | |
} | |
} | |
return largestNum; | |
} | |
console.log(findLargestNumber([74, 39, 88, 57, 29, 17, 55, 72])); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment