Building Messages
Easy+15 XP
Mission Briefing
The Grand Bazaar's merchants are struggling to write price tags manually. They need a system to dynamically stamp item names and prices onto their signage.
The Concept: String Manipulation
Instead of hardcoding values, we use variables and parameters to make code dynamic. You can combine strings and variables using Concatenation (+) or modern Template Literals (Backticks ), which let you inject variables directly using ${variable}.
The Objective
Your function receives two parameters: item (a string) and price (a number).
- Construct a dynamic message.
- The message must read exactly: "The [item] costs [price] rupees."
- Return the newly built message. Pay exact attention to spacing!
01EXAMPLE 1
Input
item = "Phone", price = 50000Output
"The Phone costs 50000 rupees."02EXAMPLE 2
Input
item = "Keyboard", price = 2500Output
"The Keyboard costs 2500 rupees."Constraints
- Use the parameters inside the string.
- Pay strict attention to the spaces in the prompt.
FundamentalsStrings
JavaScriptSystem handles I/O — write your function only
Loading...
3 Hidden
Input Arguments
item"Phone"
price50000
Expected Output
The Phone costs 50000 rupees.
Click RUN to test your solution