maximum element within a specific range in an array code example
Example 1: Obtain smallest value from array of objects in Javascript
myArray.sort(function (a, b) {
return a.Cost - b.Cost
})
var min = myArray[0],
max = myArray[myArray.length - 1]
Example 2: loop through list, find specific number and output element's index
loop through list, find specific number and output element's index
numbers = [1,5,7,8,2,34,5,23,145,87]
N = 3
if N in numbers:
print(numbers.index(N))
elif N not in numbers:
print(-1)