512.Print Your Name
Easy
Given a person's
name, return the sentence "My name is <name>.".
This is the classic first program, with one twist: instead of printing straight to the screen, the function hands its text back so it can be checked automatically. A program that prints would end with a print call such as System.out.println(result) — everything before that line is identical. The concatenationConcatenationJoining strings end to end to make one longer string, usually written with the + operator. version joins the pieces by hand; the formatted stringFormatted StringA text template with placeholders (%s, {name}) that the language fills in with values. version writes the sentence once and drops the name into a placeholder.
Example 1:
Input: name = "Asha"
Output: "My name is Asha."
Example 2:
Input: name = "Ravi Kumar"
Output: "My name is Ravi Kumar."
+ 4 hidden test cases run on Submit.
Constraints:
- ●
1 ≤ name.length ≤ 50 - ●
name contains letters and spaces only
name =
Asha