JavaScript JavaScript Basics Creating Reusable Code with Functions Create a max() Function

Guadalupe Favela
Guadalupe Favela
5,564 Points

parameters with conventional statements.

im not sure what I'm doing wrong. Can someone please help me understand? its asking me to use a conditional statement to test the 2 parameters to see which is the larger of the two.

script.js
function max(num1, num2){
return num1, num2
}

if(num1 > num2){
   return num1
   }else{
   return num2
   }

1 Answer

Antonio De Rose
Antonio De Rose
20,840 Points

why is the below if

if(num1 > num2){
   return num1
   }else{
   return num2
   }

//not inside the function, you declared.
//shouldn't it be within the function
Guadalupe Favela
Guadalupe Favela
5,564 Points

it was asking me to use a conditional statement to test the 2 parameters to see which is the larger of the two.