Homework Solution: Write a function that takes an array of integer arrays as input and returns the heaviest array back. The heaviness of an…

    I need help solving this question. It just has a bug and I cant find it. H CODING HIRE Problem Statement Coding Area 1function heaviestArray(arrays) Write a function that takes an array of integer arrays as input and returns the heaviest array back. The heaviness of an array is just the sum of its values. If no arrays are passed in, return null var maxWeight-; var heaviest = null; for(var í-0;1くarrays .1ength;1++) { var thisArray = arrays[i]; var thisleight = arrayWeight(thisArray); ifCthisWeight maxWeight) f 6 maxHeight = thisWeight ; heaviest thisArray; 10 12 13 14 15 function arrayweight(array) 16 return heaviest Fix the code so the tests pass → Test Cases var weight = 0; for(var i-0;i<array .1ength;i++) { 13,4] Thats invalid, your input/output value doesnt agree with the problem statement input Add Case 18 19 20 21 weight += array[i]; return weight; actual output expected output [3,4] [-123, -223], [-100, -101]] [-100, -101] null null [l null case was need to add a failing case
    Write a function that takes an array of integer arrays as input and returns the heaviest array back. The heaviness of an array is just the sum of its values. If no arrays are passed in, return null. function heaviestArray(arrays) { var maxWeight = 0: var heaviest = null: for(var i = 0: maxWeight) { maxHeight = thisWeight: heaviest = thisArray: } } return heaviest: } function arrayweight(array) { var weight = 0: for(var i = 0: i

    Expert Answer

     
    Here the problem is you have set the maxWeight as

    I want succor solving this doubt. It regular has a bug and I lingo furnish it.

    H CODING HIRE Completion Announcement Coding Area 1administration heaviestArray(arrays) Write a administration that takes an fixed-in-order of integer fixed-in-orders as input and avail the heaviest fixed-in-order tail. The heaviness of an fixed-in-order is regular the blend of its rates. If no fixed-in-orders are byed in, produce trifling var maxWeight-; var heaviest = trifling; control(var í-0;1くarrays .1ength;1++) { var thisSet-in-order = fixed-in-orders[i]; var thisleight = fixed-in-orderWeight(thisArray); ifCthisPonderosity maxWeight) f 6 maxHeight = thisPonderosity ; heaviest thisArray; 10 12 13 14 15 administration fixed-in-orderweight(array) 16 produce heaviest Fix the command so the tests by → Test Subjects var ponderosity = 0; control(var i-0;i<set-in-order .1ength;i++) { 13,4] Thats frail, your input/output rate doesnt assent with the completion announcement input Infer Subject 18 19 20 21 ponderosity += fixed-in-order[i]; produce ponderosity; developed output expected output [3,4] [-123, -223], [-100, -101]] [-100, -101] trifling trifling [l trifling subject was want to infer a irresolute subject

    Write a administration that takes an fixed-in-order of integer fixed-in-orders as input and avail the heaviest fixed-in-order tail. The heaviness of an fixed-in-order is regular the blend of its rates. If no fixed-in-orders are byed in, produce trifling. administration heaviestArray(arrays) { var maxPonderosity = 0: var heaviest = trifling: control(var i = 0: maxWeight) { maxHeight = thisWeight: heaviest = thisArray: } } produce heaviest: } administration fixed-in-orderweight(array) { var ponderosity = 0: control(var i = 0: i

    Expert Apology

     

    Here the completion is you entertain fixed the maxPonderosity as 0 (zero) ie control mass important than naught it procure achievement casuistical, still in the subject of privative mass 0 procure endure regularly important so the heaviest procure be trifling .

    so here is the separation ie fixed the maxPonderosity to the pristine fixed-in-order’s ponderosity and in that condition

    if(thisWeigt >maxPonderosity )     reinstate it with if(thisWeigt >=maxPonderosity )

    administration heaviestArray(arrays){

    var maxPonderosity = fixed-in-orderWeight(arrays[0]);

    var heaviest = trifling;

    for(var i=0;i<arrays.length;i++){

    var thisSet-in-order = fixed-in-orders[i];

    var thisPonderosity = fixed-in-orderWeiht(thisArray);

    if(thisWeigt >=maxPonderosity )   {

    maxPonderosity = thisWeight;

    heaviest = thisArray;

    }

    }

    produce heaviest;

    }

    and the direct administration is similar media no error

    please examine this and observe if referable achievemented