Concept Explanation
This lesson gives you a hands-on introduction to the basic syntax that makes JavaScript readable and predictable. Instead of memorizing rules in isolation, you will take a tiny script, run it, change it, and observe how the behavior changes. The goal is to get comfortable with statements, variables, conditions, and the habit of checking output after every small edit. By the end, you should be able to read a short snippet and explain what it does without guessing.
Where to Put the Code
- Start with variables and inputs. Use browser or Node.js syntax clearly.
- Add processing logic in the middle section.
- Finish with output and quick validation.
Command Reference
- Run the snippet once, then change one value and observe what prints to the console.
- Point out where variables, strings, and conditional logic appear in the example.
- Refactor the starter code so the intent is clearer without changing the result.
- Describe one everyday situation where a simple condition like this is useful.
Step-by-step Guide
- Type the starter code yourself so you notice the syntax as you write it.
- Run the script and confirm which branch of the condition executes.
- Change one value, run the code again, and compare the new output.
- Rename at least one variable to make the script easier to read.
- Summarize in one sentence what the final version of the code does.
Practice Exercises
- Create a second example that checks a different value, such as age, score, or cart total.
- Rewrite the script so the message is built with template literals instead of plain strings.
- Add one extra condition and explain how it changes the flow of the program.
Coding Challenges
- Write the same logic in two styles and decide which version is easier for a beginner to maintain.
- Make the script more robust by handling an unexpected or empty value.
Mini Practice Tasks
- Rename the main variables so their purpose is obvious at a glance.
- Add one small improvement to the output message.
- Write a one-line note describing the exact condition that triggers the console message.
Common Mistake
Skipping input validation or mixing logic/output in one unstructured block.
Real-life Mini Challenge
Build a small real-life example for this lesson topic using 3 clear steps: input, process, output.