JavaScript · Exercise 1 of 6Next
Beginner
Your first function
Write a function called greet that takes a name and returns (not prints) the text Hello, <name>!. For example, greet("Asha") returns "Hello, Asha!".
When it's called with no name at all, greet() should return "Hello, friend!".
What Check tests
- There is a function called
greet greet("Asha")returns"Hello, Asha!"- It works for any name, like
"Ravi" greet()with no argument returns"Hello, friend!"
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
Runs in your browser. Your code is saved here.
Press Run to see the page.
Console
Nothing printed yet.