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

shiny peanut
shiny peanut
4,223 Points

simple javascript question

Can you someone spot what's wrong here? The prompt tells me to write this last line as I have and I can't figure out why it isn't taking it.

script.js
function max(snacc,attacc){
  if (snacc > attacc){
    return snacc
  }else{
      return attacc
  }
 alert( max(snacc,attacc) );

}

1 Answer

KRIS NIKOLAISEN
PRO
KRIS NIKOLAISEN
Pro Student 51,087 Points

Two things:

1) Your alert should be outside your function

2) The instructions for task 2 are to pass in two numbers

shiny peanut
shiny peanut
4,223 Points

oh. my god. I am such a walnut.

Thank you fren