Generation

generate functionTue, 15 Nov 2022

sort a list and add the two largest numbers in the list.

Script function addLargestNumbers(lst){ lst.sort(); return lst[lst.length - 1] + lst[lst.length - 2]; } addLargestNumbers([1,5,6,2])

Questions about programming?Chat with your personal AI assistant