Sikau

JavaScript · Day 9 · about 25 min

Building sentences

Template literals and naming things well.

Messages with blanks

"Hello Sita, your order of 3 momo plates is ready." Apps build sentences like this all the time, filling in names and numbers. Today you'll learn the neat way to do it.

The old way: lots of +

const name = "Sita";
const plates = 3;
console.log("Hello " + name + ", your " + plates + " plates are ready.");

The rest of this lesson

  • The better way: template literalsexplain
  • Naming things wellexplain
  • Multi-line text and neat numbersexplain
  • Predict the outputpredict
  • Backticks or quotes?predict
  • Your turnwrite code
  • A receiptwrite code
  • Badge quizquiz
  • What you learnedrecap

Continue this lesson free — run real code in your browser

Continue with Google

See all 68 lessons of JavaScript