Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let removeMaximum = (array) => {
- // find maximum in array and it's index
- let maximum = 0;
- for (let i = 0; i < array.length; i++) {
- if (maximum < array[i]) {
- maximum = array[i];
- }
- }
- // remove 1 element of value maximum
- array = array.filter(function(value, index, arr){
- return value !== maximum;
- });
- return array;
- }
- let a = [1, 2, 3, 10, 5, 100, 8, 15];
- let arrayWithoutMaximum = removeMaximum(a);
- console.log(arrayWithoutMaximum);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement