Beginner

Writing Your First Function

Description

In this challenge, you'll learn how to define and use functions in JavaScript.

Functions allow you to write reusable blocks of code that perform a specific task.

Your task is to write a function named greetUser that takes a user's name as input and returns a greeting message. Functions are a fundamental part of programming, helping to structure code efficiently and avoid repetition.

Example usage:

greetUser("Alice"); // Expected output: "Hello, Alice!"
greetUser("Bob"); // Expected output: "Hello, Bob!"
greetUser(""); // Expected output: "Hello, Guest!"

window code 2Test Cases

Input:

"Bob"

Expected Output:

"Hello, Bob!"