JavaScript
The language of the web. Runs everywhere.
⚠ pattern-based checks (code is analyzed, not compiled)
About JavaScript
JavaScript powers every browser on the planet, plus Node.js on servers. It's dynamically typed, prototype-based, and incredibly flexible. NOTE: In this course, your code is checked by analyzing what you wrote (pattern matching). It is NOT actually executed. Focus on writing correct, idiomatic JavaScript.
Quick-reference cheat sheet
// JavaScript cheat-sheet
// Single-line comment
/* multi-line */
let x = 10; // mutable
const PI = 3.14; // immutable binding
var legacy = 1; // avoid in modern code
// Strings
const name = "ada";
const greet = `Hello, ${name}!`; // template literal
// Arrays / objects
const nums = [1, 2, 3];
nums.push(4);
const person = { name: "ada", age: 36 };
// Conditions
if (x > 0) {
console.log("positive");
} else if (x === 0) {
console.log("zero");
} else {
console.log("negative");
}
// Loops
for (let i = 0; i < 5; i++) console.log(i);
for (const n of nums) console.log(n);
// Functions
function add(a, b) { return a + b; }
const mul = (a, b) => a * b;
// Higher-order
nums.map(n => n * 2);
nums.filter(n => n > 1);
nums.reduce((a, b) => a + b, 0);
// Destructuring & spread
const { name: n1 } = person;
const more = [...nums, 5, 6];
// Classes
class Animal {
constructor(name) { this.name = name; }
greet() { return `hi, ${this.name}`; }
}
Tasks
- 01introHello, World!Use console.log to print a greeting.
- 02introlet and constDeclare a const PI and a let counter.
- 03introString concatenationConcatenate two strings with +.
- 04introif / elseBranch on a number.
- 05easyArrow function: addDefine an arrow function add(a, b) that returns the sum.
- 06easyTemplate literalsBuild a greeting using backtick template literals.
- 07easyfor loop 1..10console.log numbers 1 through 10.
- 08easywhile loopCount down from 5 to 1 with a while loop.
- 09easyArray pushBuild an array with .push.
- 10easyDouble with .mapUse .map() to double every number in an array.
- 11mediumFilter evensUse .filter() to keep only even numbers.
- 12mediumSum with reduceUse .reduce() to sum an array.
- 13mediumArray .findFind the first user older than 30.
- 14mediumDestructuringDestructure name and age from an object.
- 15mediumSpread operatorCombine two arrays with spread.
- 16mediumObject shorthandUse shorthand to build an object.
- 17mediumTernary expressionPick a label using ternary.
- 18mediumDefine a classClass Animal with a constructor and a method.
- 19hardExtending a classSubclass Animal with Dog.
- 20mediumJSON.stringifySerialize an object to JSON.
- 21mediumSet: unique valuesUse Set to dedupe an array.
- 22mediumMap collectionBuild a Map and set entries.
- 23mediumRegex testTest if string matches a digit pattern.
- 24hardPromise chainCreate a Promise that resolves to 42, then log it doubled.
- 25hardasync/awaitWrite an async function that awaits a Promise.
- 26hardtry / catchWrap JSON.parse in try/catch.
- 27hardClosures: counterMake a counter factory using closures.
- 28hardfetch APIFetch JSON and return its parsed body.
- 29hardGenerator functionDefine a generator yielding 1, 2, 3.
- 30hardDebounce utilityImplement a debounce helper.
- 31easyMulti-line template literalUse backticks with newlines and ${}.
- 32easyStrict vs loose equalityUse === instead of ==.
- 33easyArrow function shorthandSingle-expression arrow.
- 34easyDefault parametersFunction with a default arg.
- 35mediumRest + spreadSum any number of args.
- 36mediumObject destructuring + renameDestructure with alias.
- 37mediumArray destructure + skipSkip middle element.
- 38mediumOptional chaining + nullish?. and ?? together.
- 39mediumArray.findGet the first match.
- 40mediumevery & someAll positive? Any negative?
- 41mediumArray.flatMapSplit sentences into words.
- 42mediumSet: unique valuesDedupe an array via Set.
- 43mediumMap collectionUse Map with .set and .get.
- 44mediumObject.entries loopIterate key/value with for...of.
- 45mediumJSON parse + stringifyRoundtrip an object.
- 46hardClass with getterDefine a get accessor.
- 47hardClass extends + superSubclass with super().
- 48hardPrivate class fieldUse #field syntax.
- 49hardnew PromiseWrap a setTimeout in a Promise.
- 50hardasync / await + tryAwait with error handling.
- 51hardPromise.allWait for parallel promises.
- 52hardGenerator functionfunction* with yield.
- 53hardIterable via Symbol.iteratorCustom iterable object.
- 54hardClosure: makeCounterReturn functions sharing state.
- 55hardThrottle utilityLimit calls to once per ms.
- 56hardCurryingCurry a 3-arg function.
- 57hardstructuredClone deep copyClone a nested object.
- 58hardRegex named groupsMatch a date with (?<year>...).
- 59hardProxy interceptionTrap property access with Proxy.
- 60easyModulo: check evenUse % to log whether 14 is even.
- 61easyString lengthLog the length of a string.
- 62easyUppercase a stringConvert a string to UPPERCASE.
- 63easyString.includesCheck if a string contains a substring.
- 64easySlice a substringExtract characters with .slice.
- 65easySplit a CSV lineSplit a comma-separated string into an array.
- 66mediumArray.join with separatorJoin words with dashes.
- 67mediumSort numbers ascendingSort with a comparator (default sort is lexicographic!).
- 68mediumArray.from a rangeBuild [1,2,3,4,5] with Array.from.
- 69mediumRoll a die (1–6)Generate a random integer 1–6.
- 70mediumObject.keysGet the keys of an object as an array.
- 71mediumLoop with Object.entriesIterate key/value pairs with for...of and Object.entries.
- 72mediumNullish coalescing (??)Default only when null/undefined (not 0 or '').
- 73mediumLogical OR assignment (||=)Assign only if the current value is falsy.
- 74mediumString.replaceAllReplace every occurrence of a substring.
- 75hardTagged template literalDefine a tag function that uppercases interpolated values.
- 76hardPromise.allSettledAwait all promises, including the rejected ones.
- 77hardPromise.race for timeoutsRace a real promise against a timeout rejection.
- 78hardfor await...of an async iterableConsume an async generator with for await...of.
- 79hardWeakMap as a private cacheCache per-object data without leaking memory.
- 80hardRecursive deep flattenFlatten any-depth nested array WITHOUT using .flat(Infinity).
- 81hardMemoize an expensive functionCache results of pure function calls in a closure + Map.
- 82hardCapstone: TodoList classBuild a TodoList class with add / toggle / remove / filter (active|done|all).
