Before writing anything, get clear on what is being asked.
Think of it like this
Think of text like beads on a string. "Hello, " is one bead, the name is another, "!" is a third. Joining them threads the beads together in the order you choose — change the order and you get a different necklace.
The most common first mistake is printing instead of returning. Printing shows something on the screen; returning hands the value back to whoever asked. The tests can only see what you return.
Write a function that takes someone’s name and gives back a greeting for them.
If the name is `Ada`, the greeting is `Hello, Ada!` — the word Hello, then a comma and a space, then the name, then an exclamation mark.
Example 1
Given name = "Sathish"
Answer "Hello, Sathish!"
The name goes between "Hello, " and "!".
Example 2
Given name = "Ada"
Answer "Hello, Ada!"
Write the function in the editor, then run it against the examples.
The editor on the right already has the function signature filled in for you. Write your answer inside it and press Run — that checks your code against the examples above only, so you can experiment freely.
Each one nudges you a little further. There is no reveal-the-answer button — working it out is the part that actually teaches you.
Submit against every test, then check you can explain why it works.
Take the fixed text before the name, add the name, then add the fixed text after it. That is the whole exercise — and it is genuinely how every program that builds a message works.
return "Hello, " + name + "!"What is the difference between printing a value and returning it?
Run your code to see the test results.
⌘/Ctrl + Enter to run · ⌘/Ctrl + Shift + Enter to submit
Before writing anything, get clear on what is being asked.
Think of it like this
Think of text like beads on a string. "Hello, " is one bead, the name is another, "!" is a third. Joining them threads the beads together in the order you choose — change the order and you get a different necklace.
The most common first mistake is printing instead of returning. Printing shows something on the screen; returning hands the value back to whoever asked. The tests can only see what you return.
Write a function that takes someone’s name and gives back a greeting for them.
If the name is `Ada`, the greeting is `Hello, Ada!` — the word Hello, then a comma and a space, then the name, then an exclamation mark.
Example 1
Given name = "Sathish"
Answer "Hello, Sathish!"
The name goes between "Hello, " and "!".
Example 2
Given name = "Ada"
Answer "Hello, Ada!"
Write the function in the editor, then run it against the examples.
The editor on the right already has the function signature filled in for you. Write your answer inside it and press Run — that checks your code against the examples above only, so you can experiment freely.
Each one nudges you a little further. There is no reveal-the-answer button — working it out is the part that actually teaches you.
Submit against every test, then check you can explain why it works.
Take the fixed text before the name, add the name, then add the fixed text after it. That is the whole exercise — and it is genuinely how every program that builds a message works.
return "Hello, " + name + "!"What is the difference between printing a value and returning it?