mercredi 2 décembre 2020

Name Greeting Function Javascript Question

//Hi I'm still a beginner to programming and I really want to learn why this program is not working. I recently learned about function and if and else statements so I tried my best to answer the question to the best of my ability but, I keep getting an error. Can you help me please? Thank you.

//Question: Define a function, defaultGreet, that takes a first and a last name. defaultGreet should return a string greeting for the given names. If the user does not define the last name, assume the last name is 'Doe'.

**function defaultGreet(a,b) 
{
 if (a&&b === true){
   return ("Hi" + a + b + "!")
 }
}
else {
  return ("Hi" + a + "Doe" + "!") 
}
defaultGreet(john,smith)
defaultGreet(john)**

Aucun commentaire:

Enregistrer un commentaire