![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](https://d2vlcm61l7u1fs.cloudfront.net/media%2F0ca%2F0ca96dce-5a72-4f0b-a630-8d176846c9e0%2FphpvPY97D.png)
I want succor solving this doubt. It regular has a bug and I lingo furnish it.
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
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