Ryan Aulia

Grasshopper - Personalized Message

# Problem Solving
Problem
Create a function that gives a personalized greeting. This function takes two parameters: name and owner.
Use conditionals to return the proper message:
CaseReturn
name equals owner'Hello boss'
otherwise'Hello guest'
 
Solution
Create a function that generates a personalized greeting. This function takes two parameters: name and owner.
Use conditionals to return the proper message:
If name equals owner, return 'Hello boss'. Otherwise, return 'Hello guest'.
In this solution, the greet function uses a ternary conditional operator to check whether name === owner. If they are equal, the function returns 'Hello boss'; otherwise, it returns 'Hello guest'.
JavaScript Playground
JavaScript
Loading...
Console