JavaScript
Working with data types
A practical reference with examples you can run.
Introduction
Numbers, text, and true-or-false values behave differently. Adding numbers calculates a sum; combining strings joins text. Convert a value deliberately before using it in a calculation.
Syntax & example
const price = 12; const quantity = 3; console.log(price * quantity);
Expected output
36
Common mistakes
- Using a variable before assigning a value to it.
- Mixing text and numbers without converting deliberately.
- Skipping an empty input or a boundary value when testing.
Practice
Store a price and a quantity, then calculate their product.
main.jsYour ideas, in code.
Loading your editor…
Run your code to see the output here.
Ready to buildUTF-83 lines