Challenge

Problem

Welcome to CrackedRuby! This is your first drill to get familiar with the platform. You'll write a simple Ruby method that returns a greeting message.

Difficulty: Beginner

Instructions

  1. Complete the greet method in main.rb
  2. The method should accept a name parameter
  3. Return 'Hello, [name]!' (with the name capitalized)
  4. If no name is provided, return 'Hello, World!'
  5. Click 'Run Code' to test your solution
  6. Click 'Submit' when all tests pass

Files

Editable

Hints

Hint 1

Use the `capitalize` method to ensure the first letter is uppercase and the rest lowercase

Hint 2

Remember to check if name is `nil` before processing it

Hint 3

String concatenation with + or string interpolation with both work

Hint 4

The default parameter syntax is `name = nil` in the method signature

1. No name provided - returns 'Hello, World!'

Input:
puts greet
Expected Output:
Hello, World!

2. Name provided - returns greeting with capitalized name

Input:
puts greet('alice')
Expected Output:
Hello, Alice!

3. Mixed case name gets properly capitalized

Input:
puts greet('rUBy')
Expected Output:
Hello, Ruby!

4. All caps name gets properly capitalized

Input:
puts greet('CHARLIE')
Expected Output:
Hello, Charlie!
+ 1 hidden test case