Concept Flow - Output formatting basics
Start
Prepare data
Choose format method
Apply formatting
Print or return formatted output
End
This flow shows how data is prepared, formatted, and then output in JavaScript.
const name = "Alice"; const age = 30; console.log(`Name: ${name}, Age: ${age}`);
| Step | Action | Evaluation | Result |
|---|---|---|---|
| 1 | Declare variable name | name = "Alice" | name holds "Alice" |
| 2 | Declare variable age | age = 30 | age holds 30 |
| 3 | Format string with template literal | `Name: ${name}, Age: ${age}` | "Name: Alice, Age: 30" |
| 4 | Print formatted string | console.log output | Name: Alice, Age: 30 |
| 5 | End of code | No more statements | Execution stops |
| Variable | Start | After Step 1 | After Step 2 | Final |
|---|---|---|---|---|
| name | undefined | "Alice" | "Alice" | "Alice" |
| age | undefined | undefined | 30 | 30 |
Output formatting basics in JavaScript:
- Use backticks (`) for template literals.
- Embed variables with ${variable} inside strings.
- Use console.log() to print formatted output.
- Single/double quotes do not substitute variables.
- Template literals make output readable and dynamic.