Greeting
Difficulty Rating: 1/5
See the Pen 42fdcc5a847fe8ddc6dea27145d1cda0 by Fullstack Academy (@FullstackAcademy) on CodePen.
Click on a hint if you get stuck or review the solution.
Hint-1: Two Outputs
There are two different outputs
Output 1:
'Hello, '+ name + '!';
Output 2:
'Hello!';
How do you execute two separate code blocks based on a condition?
EX: If the condition is true
, run a block of code, if the condition returns false
, run a different block of code.
Hint-2: The Condition
- What condition is tested in the
if/else
statement? The condition should test if an argument (the name) is passed to thegreeting
function. Review the idea of truthy and falsy values. - What value is assigned to a parameter if an argument isn't passed to a function?
- The condition tests if an argument is passed to the
greeting
function. If an argument is passed, return the string: - If an argument isn't passed return the string:
'Hello, '+ name + '!';
'Hello!';