Advertisement
nutter666

compareValues

May 6th, 2014
493
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. function compareValues(listOfTheValues){
  2.  
  3. list = listOfTheValues
  4.  
  5. var bestValue
  6.  
  7. bestValue = list[0]
  8. // set the bestValue to the first one in the last
  9.  
  10. // run through the remainder of the list
  11. for(var i:int = 1;i<=list.length-1;i++){
  12. if(list[i] > bestValue){
  13. bestValue = list[i]
  14. }
  15.  
  16. // if any of the list items are better (greater in this case) than the current bestValue, replace the bestValue
  17.  
  18. }
  19.  
  20. // return the bestValue once the list has been ran though
  21. return bestValue
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement