javascript - How to remove the minimum number from multiple arrays -


//here code:

    function removesmallest(arr) {       var min = math.min.apply(null, arr);       return arr.filter((e) => {return e != min});       }        console.log(removesmallest([2,1,3,5,4], [5,3,2,1,4], [2,2,1,2,1])); 

/*the issue need third array output [2,2,2,1]. code doing telling removing smallest number in each array sake of problem, need take out 1 of ones(if makes sense). appreciate help! */

you need change logic slightly. find minimum number in array, use find first index of number, , remove specific number.

function removesmallest(arr) {   var min = math.min.apply(null, arr);   arr.splice(arr.indexof(min), 1);    return arr; } 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -