How to get the correct array to return from this function

I think my logic is clear, but this wont return the array I need. How do I accomplish this?


let arrCompareSetter = function(arr1, arr2){arr1.length > arr2.length ? return arr1 : return arr2}

try this. I think this is what you tried to achieve →

let arrCompareSetter = function(arr1, arr2){
 return arr1.length > arr2.length ? arr1 :  arr2
}

Im not really sure on what to say about the correct reason but I can say this → Either use an if/else ternary operator or a ternary with a return before, not after .

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.