COURSE · 10 chapters · 89 lessons

JavaScript

Build the way of thinking that programming runs on

Read about this chapter

Show text and numbers

  1. 01Your first JavaScriptUse console.log to put what you wrote up on the screen.6 slides · 13 exercisesGo to the exercises
  2. 02Text and numbers are different thingsWrapped in " it is text, left bare it is a number. Learn to tell them apart.5 slides · 13 exercisesGo to the exercises
  3. 03Doing some mathsUse + - * to work numbers out and show the answer.5 slides · 13 exercisesGo to the exercises
  4. 04Dividing, and what is left overDivide with / and get the remainder with %.6 slides · 13 exercisesGo to the exercises
  5. 05Joining text togetherThe same + adds numbers up but joins strings. Let us see it happen.6 slides · 13 exercisesGo to the exercises

Give a value a name

  1. 06Meet the variableGive a value a name so you can reach for it again and again.5 slides · 13 exercisesGo to the exercises
  2. 07Why bother with variablesReuse a value, say what it means, and keep the edit in one place. Feel the three things a variable gives you.6 slides · 13 exercisesGo to the exercises
  3. 08Changing what is in a variablePut a different value into a variable you already made.6 slides · 13 exercisesGo to the exercises
  4. 09Writing an update the short wayWrite count = count + 1 as += or ++ instead.7 slides · 13 exercisesGo to the exercises
  5. 10Meet the constantDeclare a value you are never going to change with const.5 slides · 13 exercisesGo to the exercises
  6. 11Dropping a variable into some textUse a backtick and ${} to write something easier to read than a chain of +.6 slides · 13 exercisesGo to the exercises

Branch on a condition

  1. 12Doing something only ifUse if to write code that only runs when a condition holds.5 slides · 13 exercisesGo to the exercises
  2. 13true and falseA condition is really just a value: true or false. See for yourself that comparing gives you one back.5 slides · 13 exercisesGo to the exercises
  3. 14Checking whether two things are the sameUse === for "the same" and !== for "not the same".4 slides · 13 exercisesGo to the exercises
  4. 15Writing the "otherwise" partUse else to say what happens when the condition does not hold.4 slides · 13 exercisesGo to the exercises
  5. 16Splitting three ways or moreLine up else if and let the conditions be tried from the top.4 slides · 13 exercisesGo to the exercises
  6. 17Combining conditionsFold several conditions into one with && (and), || (or) and ! (not).5 slides · 13 exercisesGo to the exercises
  7. 18Sorting by valueUse switch to branch on which value one thing matches.5 slides · 13 exercisesGo to the exercises
  8. 19When nothing matchesCatch the values you did not expect with a switch default.4 slides · 13 exercisesGo to the exercises