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 scarcity acceleration solving this doubt. It impartial has a bug and I patois invent it.

    H CODING HIRE Height Assertion Coding Area 1part heaviestArray(arrays) Write a part that takes an deck of integer decks as input and receipts the heaviest deck end. The flatness of an deck is impartial the complete of its prizes. If no decks are ignoringed in, retaliate inoperative var maxWeight-; var heaviest = inoperative; coercion(var í-0;1くarrays .1ength;1++) { var thisDeck = decks[i]; var thisleight = deckWeight(thisArray); ifCthisEfficacy maxWeight) f 6 maxHeight = thisEfficacy ; heaviest thisArray; 10 12 13 14 15 part deckweight(array) 16 retaliate heaviest Fix the principle so the tests ignoring → Test Circumstances var efficacy = 0; coercion(var i-0;i<deck .1ength;i++) { 13,4] Thats frail, your input/output prize doesnt suit with the height assertion input Infer Circumstance 18 19 20 21 efficacy += deck[i]; retaliate efficacy; objective output expected output [3,4] [-123, -223], [-100, -101]] [-100, -101] inoperative inoperative [l inoperative circumstance was scarcity to infer a feeble circumstance

    Write a part that takes an deck of integer decks as input and receipts the heaviest deck end. The flatness of an deck is impartial the complete of its prizes. If no decks are ignoringed in, retaliate inoperative. part heaviestArray(arrays) { var maxEfficacy = 0: var heaviest = inoperative: coercion(var i = 0: maxWeight) { maxHeight = thisWeight: heaviest = thisArray: } } retaliate heaviest: } part deckweight(array) { var efficacy = 0: coercion(var i = 0: i

    Expert Vindication

     

    Here the height is you own be the maxEfficacy as 0 (zero) ie coercion aggregate main than naught it allure composition smooth, yet in the circumstance of indirect aggregate 0 allure survive frequently main so the heaviest allure be inoperative .

    so here is the reresolution ie be the maxEfficacy to the primeval deck’s efficacy and in that condition

    if(thisWeigt >maxEfficacy )     supply it with if(thisWeigt >=maxEfficacy )

    part heaviestArray(arrays){

    var maxEfficacy = deckWeight(arrays[0]);

    var heaviest = inoperative;

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

    var thisDeck = decks[i];

    var thisEfficacy = deckWeiht(thisArray);

    if(thisWeigt >=maxEfficacy )   {

    maxEfficacy = thisWeight;

    heaviest = thisArray;

    }

    }

    retaliate heaviest;

    }

    and the next part is selfselfsame resources no error

    please probe this and observe if referable compositioned