Command Palette

Search for a command to run...

Hectal
Phase 3: Functions
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

  1. There is a function called greet
  2. greet("Asha") returns "Hello, Asha!"
  3. It works for any name, like "Ravi"
  4. 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.

Console

Nothing printed yet.