Search code examples
javascriptfunctionjscript

basic function in javascript not working


Hi this is my very first time here and I'm struggling since I'm first timer learning to code. I presume when I try to pass the arguments to the parameters, it gets confused, or maybe I'm missing something very simple. Where am I missing or failing here? I just doesn't work...

  function adultCheck(age,name) {
  if (age <= 17) {
    alert("Sorry " + name ", you are not allowed to see this, you are too young.");
  } else {
    alert("Welcome " + name ", you are " + age "  visit our lounge!");
  }

}

adultCheck(15,Tami);

Solution

  • You also forgot to add an additional + after the variables: "" + name + ""