How do I design an algorithm to find the biggest number in a list of numbers?
I also need 开发者_运维技巧to convert my answer into javascript code that displays the largest value.
alert(Math.max(13, 42, 86, 3, 25)); // 86
I guess you just need something on the lines of:
var mx = list[0];
for (i=1; i<length(list); i++)
mx = Math.max(mx, list[i])
alert(mx)
精彩评论