You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
649 B
18 lines
649 B
# Morning Exercise
|
|
|
|
With these morning exercises, we want you to think about how to, not only tackle the problem, but to see how effeciently you can solve them. Solve this one in **two** different ways.
|
|
|
|
## The Biggest Difference
|
|
|
|
Write a function that takes in the array and returns the **largest difference** between any **two** of its elements. You can assume that the array is all numbers and that there are no duplicates.
|
|
|
|
The starter code:
|
|
``` javascript
|
|
var biggestDifference = function(arr){
|
|
// code goes here...
|
|
}
|
|
|
|
biggestDifference([1,4,7,3,2]) // would return 6
|
|
biggestDifference([9, 20, 5, -6, -1, 8]) // would return 26
|
|
```
|