StreetDocsPlayground
StreetDocs/Make Your Web Page Smart/Variables — Counting Market Prices
javascript
12 minLearning in Pidgin

Variables — Counting Market Prices

Use variables to hold Ada's market prices.

What you'll learn

  • Know wetin variable be
  • Create variables with let
  • Store numbers and text inside them

Every morning Ada dey go market and buy food ingredients. She fit calculate how much she spend. But computer no sabi count by itself — we need to teach am with variables.

Wetin be a variable?

A variable na a box with a name, wey dey hold one value. To create am, use let:

let priceOfRice = 850;
let priceOfBeans = 450;

Na like say Ada get two bags wey dem mark: one "rice" with 850 inside, one "beans" with 450 inside. Later, anytime you write priceOfRice, di computer know say you mean 850.

Di = here no mean "equal". E mean "put dis value inside dis box". And remember — priceOfRice and priceofrice na two different things. Names dey case-sensitive.

Try it yourself

javascript
let priceOfRice = 850;
let priceOfBeans = 450;
console.log(priceOfRice);
Output:
850

Quiz

Small check

Answer di questions below.

1. Which keyword dey create a variable?

2. Which one na valid variable name?