StreetDocsPlayground
javascript
12 minLearning in Pidgin

Numbers and Text

Add Ada's prices together and work with text.

What you'll learn

  • Add and subtract numbers
  • Join text with strings
  • Use console.log to see results

Before you start

  • variables

Ada don record her prices. Now she wan know how much rice and beans go cost together. JavaScript fit do di addition for am.

Numbers

let priceOfRice = 850;
let priceOfBeans = 450;
let total = priceOfRice + priceOfBeans;
console.log(total);

+ dey add, - dey subtract, * dey multiply, / dey divide. Di result go print for di console as 1300.

Strings

Text for JavaScript na string — write am inside quotes. + fit join strings together, wey dem call concatenation:

let message = "Today's total is " + total;
console.log(message);

Na like Ada dey tell customers: "Today's total is 1300". You go see am for console.

Try it yourself

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

Practice exercises

Exercise 1: Add di prices

Create two variables with 850 and 450, add dem together, and print di total with console.log.

Preview
Console

No output yet. Click Run.

Code runs in your browser only — nothing is sent to the server.