Tell us what’s happening:
am i using the && operators wrong? thanks
Your code so far
function largestOfFour(arr) {
var forest=[]
for(var i=0 ; i<arr.length;i++){
if(arr[i][0]>(arr[i][1]) && (arr[i][2]) && (arr[i][3])){
forest.push(arr[i][0]);
}
else if(arr[i][1]>(arr[i][2]) && (arr[i][3])){
forest.push(arr[i][1])
}
else if(arr[i][2]>arr[i][3]){
forest.push(arr[i][2])
}
else{
forest.push(arr[i][3])}
}
return forest;
}
largestOfFour([[17, 23, 25, 12], [25, 26, 34, 48], [4, -10, 18, 21], [-72, -3, -17, -10]]);
console.log(largestOfFour([[17, 23, 25, 12], [25, 24, 34, 48], [4, -10, 18, 21], [-72, -3, -17, -10]]))
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36
.
Challenge: Return Largest Numbers in Arrays
Link to the challenge: