COURSE · 12 chapters · 96 lessons
JavaScript
Build the way of thinking that programming runs on
Your progress
0 / 1239 solvedCounted from the record kept on this device.
Show text and numbers
- 01Your first JavaScriptUse console.log to put what you wrote up on the screen.6 slides · 13 exercisesGo to the exercises
- 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
- 03Doing some mathsUse + - * to work numbers out and show the answer.5 slides · 13 exercisesGo to the exercises
- 04Dividing, and what is left overDivide with / and get the remainder with %.6 slides · 13 exercisesGo to the exercises
- 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
- 06Meet the variableGive a value a name so you can reach for it again and again.5 slides · 13 exercisesGo to the exercises
- 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
- 08Changing what is in a variablePut a different value into a variable you already made.6 slides · 13 exercisesGo to the exercises
- 09Writing an update the short wayWrite count = count + 1 as += or ++ instead.7 slides · 13 exercisesGo to the exercises
- 10Meet the constantDeclare a value you are never going to change with const.5 slides · 13 exercisesGo to the exercises
- 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
- 12Doing something only ifUse if to write code that only runs when a condition holds.5 slides · 13 exercisesGo to the exercises
- 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
- 14Checking whether two things are the sameUse === for "the same" and !== for "not the same".6 slides · 13 exercisesGo to the exercises
- 15Writing the "otherwise" partUse else to say what happens when the condition does not hold.6 slides · 13 exercisesGo to the exercises
- 16Splitting three ways or moreLine up else if and let the conditions be tried from the top.4 slides · 13 exercisesGo to the exercises
- 17Combining conditionsFold several conditions into one with && (and), || (or) and ! (not).5 slides · 13 exercisesGo to the exercises
- 18Sorting by valueUse switch to branch on which value one thing matches.5 slides · 13 exercisesGo to the exercises
- 19When nothing matchesCatch the values you did not expect with a switch default.4 slides · 13 exercisesGo to the exercises
Repeat the same work
- 20A quick recapBring variables and branching back to mind before we start the new chapter.4 slides · 13 exercisesGo to the exercises
- 21Repeating with whileGet the same work done over and over, for as long as a condition holds.6 slides · 13 exercisesGo to the exercises
- 22Repeating with forLearn the other way of writing a loop, with the start, the condition and the update all on one line.6 slides · 13 exercisesGo to the exercises
- 23Choosing between the two loopsGet a feel for how to decide whether to reach for while or for.4 slides · 13 exercisesGo to the exercises
Line values up in an array
- 24Holding values together in an arrayLearn how to keep several values together in a single container.4 slides · 13 exercisesGo to the exercises
- 25Taking one item out of an arrayName a position and take a single value out of the array.6 slides · 13 exercisesGo to the exercises
- 26Changing what is in an arrayName a position and swap an item out for something else.6 slides · 13 exercisesGo to the exercises
- 27Working through an array with a loopStep the number up one at a time and handle the items in order.5 slides · 13 exercisesGo to the exercises
- 28Using the length of an arrayTake the number of items with .length and let the array decide the number of laps.5 slides · 13 exercisesGo to the exercises
Hold values by name with objects
- 29Holding values by name with an objectLearn the other way of holding data — gathering information up as name and value pairs.4 slides · 13 exercisesGo to the exercises
- 30Reading and writing propertiesName a property to take its value, change it, or add a new one later on.4 slides · 13 exercisesGo to the exercises
- 31Putting objects in an arrayLine objects of the same shape up in an array and reach values out of the nesting.4 slides · 13 exercisesGo to the exercises
- 32Running a loop over the nestingPut a for over an array of objects to list them out and add them up.6 slides · 13 exercisesGo to the exercises
When there is no value
- 33Peeking at a value that is not thereMeet undefined, the value you get back when you ask for a number or a property that does not exist.4 slides · 13 exercisesGo to the exercises
- 34Checking for undefined and stepping around itSpot the case where there is no value with a branch, and switch to a different display or a different route.5 slides · 13 exercisesGo to the exercises
Put it together
- 35Putting the chapter togetherCombined practice using arrays, objects, loops and branching together. As a round-up there are no basics — just the ten practice questions.3 slides · 10 exercisesGo to the exercises
- 36Tidying up the outputCombined practice on headings, numbers, separators and units, to finish with output people can read. As a round-up there are no basics — just the ten practice questions.3 slides · 10 exercisesGo to the exercises
More combined practice
- 37Putting for and arrays togetherLearn the single most important pattern there is: working through every item of an array with a for loop.5 slides · 13 exercisesGo to the exercises
- 38Putting for, if and arrays togetherGet to where you can handle "only the items that match" out of the whole lot.7 slides · 13 exercisesGo to the exercises
- 39Putting for, if-else and arrays togetherGet to where you can send every item down "one way or the other".6 slides · 13 exercisesGo to the exercises
- 40Putting for, if-else if and arrays togetherTake on the culminating pattern: sorting every item into three or more groups.6 slides · 13 exercisesGo to the exercises
Write a function and call it
- 41Giving work a nameGather some work into one lump so that you can call it up by name.5 slides · 13 exercisesGo to the exercises
- 42Putting a function in a variableA function is a value too. Learn the way of writing that puts one in a variable first.4 slides · 13 exercisesGo to the exercises
- 43Writing it short with an arrow functionUse
=>to write a function expression in a much shorter form.4 slides · 13 exercisesGo to the exercises
Pass values in as arguments
- 44Handing a value to a functionHand a value in inside the brackets and make a function whose result changes every time you call it.5 slides · 13 exercisesGo to the exercises
- 45Catching more than one valueHand over several values separated by
,and catch them in the order you wrote them.5 slides · 13 exercisesGo to the exercises
Send a return value back
- 46Sending a result back out of a functionSend a result back with
returnand catch it where you called from.5 slides · 13 exercisesGo to the exercises - 47Using a return value where it standsDrop a return value straight into a condition or a sum without putting it in a variable.4 slides · 13 exercisesGo to the exercises
Where a variable is visible
- 48How far a variable reachesGet straight how far a variable made inside a function can be seen.5 slides · 13 exercisesGo to the exercises
Put it together
- 49Pulling functions togetherA round-up of exercises solved by combining functions, parameters, return values and scope. Being a round-up, there are no three basics — just ten to practise on.3 slides · 10 exercisesGo to the exercises
The blueprint and the real thing
- 50Objects, one more timeRemember the shape that holds information as name-and-value pairs. No new grammar here; this one is for getting the feel back.4 slides · 13 exercisesGo to the exercises
- 51A class is a blueprint for one shapeMeet the thinking and the writing behind the class, the blueprint for turning out objects of the same shape.4 slides · 13 exercisesGo to the exercises
- 52Making a real one from the blueprintBring a real one into being from a blueprint with
new, give it properties and read them back. That real one is called an instance.4 slides · 13 exercisesGo to the exercises
Set values up as you create
- 53Work that runs by itself as you make oneSee for yourself how a constructor written inside a class runs by itself every time you
new.4 slides · 13 exercisesGo to the exercises - 54Giving it contents with thisWrite
this.name = valueinside the constructor and have the properties ready the moment it is made.4 slides · 13 exercisesGo to the exercises - 55Handing values over as you make oneHave the constructor catch arguments and give each real one different contents.5 slides · 13 exercisesGo to the exercises
Give it behaviour
- 56Giving a class something it can doCall a method — a function written inside a class — from an instance.4 slides · 13 exercisesGo to the exercises
- 57Looking at your own contents from a methodWrite
this.propertyinside a method and use the values held by the very thing it was called on.4 slides · 13 exercisesGo to the exercises - 58Calling one method from anotherWrite
this.otherMethod()inside a method and put pieces of work together.4 slides · 13 exercisesGo to the exercises
Inherit, then change what differs
- 59Building on a class you already haveUse
extendsto make a new class that takes over the contents of one you already have.4 slides · 13 exercisesGo to the exercises - 60Using what you took overCall a method written on the parent class from an instance of the child class.6 slides · 13 exercisesGo to the exercises
- 61Adding something the child alone can doWrite a method of its own on the child class and give it behaviour the parent does not have.4 slides · 13 exercisesGo to the exercises
- 62Swapping out behaviour you took overRewrite a method of the same name on the child and change the behaviour for that child alone.4 slides · 13 exercisesGo to the exercises
- 63Calling the parent's work, then adding to itUse
super()when you rewrite a constructor on the child, andsuper.method()to call the parent's method.5 slides · 13 exercisesGo to the exercises
Split files and join them back
- 64When one file gets fatSee where it hurts to keep writing everything in one place, and try cutting it up by what each part does.5 slides · 13 exercisesGo to the exercises
- 65Split the files and join them upSend things out with
export defaultand pull them in withimport. Learn the smallest shape that joins two files.5 slides · 13 exercisesGo to the exercises - 66Sending values out of a fileNot only functions — strings, arrays and objects go out with
export defaulttoo. Try putting data in its own file.5 slides · 13 exercisesGo to the exercises - 67Send out several, each with a namePublish more than one thing from a single file, and pull in only what you need with
{ }.6 slides · 13 exercisesGo to the exercises - 68Pointing at where a file isGet hold of what
./and../mean, so files sorted into folders can be joined up too.5 slides · 13 exercisesGo to the exercises
Use parts that already exist
- 69Borrowing code someone else wroteMeet the idea of pulling in ready-made code as a package, and see how you would get hold of one.6 slides · 13 exercisesGo to the exercises
- 70Calling what a package offersPull in functions a package published by name, and put their return values together.5 slides · 13 exercisesGo to the exercises
Array methods
- 71Adding to the back of an arrayUse the push method so you can add an item to the end of an array.5 slides · 13 exercisesGo to the exercises
- 72Doing the same thing to every itemHand a function to the forEach method and deliver the same work to every item of an array.6 slides · 13 exercisesGo to the exercises
- 73Finding the one that matchesHand a condition function to the find method and take out the first item that matches.5 slides · 13 exercisesGo to the exercises
- 74Collecting everything that matchesUse the filter method to make a new array of just the items that match a condition.5 slides · 13 exercisesGo to the exercises
- 75Rebuilding every itemUse the map method to make a new array of the results of converting each item.5 slides · 13 exercisesGo to the exercises
- 76Folding into one valueUse the reduce method to sum array elements or fold them into a single value.5 slides · 13 exercisesGo to the exercises
Callback functions
- 77Remembering that a function is a valueA refresher on the feel of carrying a function around as a value. No new grammar here.3 slides · 13 exercisesGo to the exercises
- 78Catching a function as an argumentLearn how to catch a function as an argument and call it, and build the machinery of a callback function with your own hands.5 slides · 13 exercisesGo to the exercises
- 79Writing the function on the spotWrite a nameless function straight where the argument goes, and get the handing over done in one.4 slides · 13 exercisesGo to the exercises
- 80Handing values to a callbackHand values over as you call the function you caught, and build the machinery by which a callback catches arguments.5 slides · 13 exercisesGo to the exercises
Loop without counting
- 81Looping without numbersTake an array one item at a time in the form
for (const fruit of fruits), with no number to keep.6 slides · 13 exercisesGo to the exercises
Pull out only what you need
- 82Taking things out of an objectTurn just the entries you need into variables all at once, in the form
const { name, age } = user;.6 slides · 13 exercisesGo to the exercises - 83Taking things out of an arrayTurn an array's contents into variables from the front in order, in the form
const [first, second] = ranking;.5 slides · 13 exercisesGo to the exercises
Spread out, and gather up
- 84Spreading things outBuild a new array or object, leaving the original as it was, in the form
[...fruits, "peach"].6 slides · 13 exercisesGo to the exercises - 85Arguments that catch any numberCatch any number of arguments and handle them as an array, in the form
function total(...numbers) {}.5 slides · 13 exercisesGo to the exercises
Follow a value that may be missing
- 86Following an entry that may not be thereUse
?.so you can follow past an entry that may not be there without stopping.5 slides · 13 exercisesGo to the exercises
Map and Set
- 87Map, which holds key and value pairsMake a
new Map()and add, take and count key and value pairs.6 slides · 13 exercisesGo to the exercises - 88Set, a collection with no duplicatesUse
new Set()to build a collection where the same value cannot go in twice.5 slides · 13 exercisesGo to the exercises
Catch an error
- 89Not stopping at an errorWrite the work that might fail in the
try, and what to do when it failed in thecatch.5 slides · 13 exercisesGo to the exercises
Throw your own error
- 90Throwing an error yourselfTurn an odd value away on the spot with
throw, and catch it on the calling side.5 slides · 13 exercisesGo to the exercises
Hand data off with JSON
- 91Converting to and from JSONTurn objects into strings with JSON.stringify, and restore them with JSON.parse.5 slides · 13 exercisesGo to the exercises
Work with dates and times
- 92Working with dates and timesUse the Date class to create timestamps, inspect years, months, and days, and compare dates.5 slides · 13 exercisesGo to the exercises
Check the shape of text
- 93Testing text patternsUse RegExp (regular expressions) to test if strings match specific patterns like digits and lengths.5 slides · 13 exercisesGo to the exercises
The basics of Promise
- 94Boxes of promises (Promise)Create a Promise, resolve the outcome, and receive it with .then().5 slides · 13 exercisesGo to the exercises
Write it with async / await
- 95Waiting in sequence (async / await)Use await inside async functions to write asynchronous code straight from top to bottom.5 slides · 13 exercisesGo to the exercises
Prepare for asynchronous errors
- 96Guarding against async errorsCatch await failures using try / catch so network issues do not crash the application.5 slides · 13 exercisesGo to the exercises