Organizing Code and Data
The first few chapters taught you how to write short programs. This part teaches you how to keep programs understandable as they grow. Without organization, code turns into a long list of steps. That works for tiny examples, but it does not work for real programs. You need ways to name repeated actions, store lists of information, group related details, and work with text without writing the same logic again and again. Functions let you give a name to a reusable action. Arrays let you store ordered lists. Objects let you describe one thing with several related properties. String methods help you clean, search, split, and build text. The part ends with a console to-do list project. It is deliberately plain. No browser interface yet. The goal is to practice the data and logic first, before the page adds another layer. By the end of this part, you should be able to model simple real-world information in JavaScript. A task, a user, a shopping cart item, a quiz question, or a score record will no longer feel like vague ideas. You will know how to represent them with arrays and objects, then write functions that work with them.
Chapters
Functions
Functions let you give a name to a reusable action. You have already used functions. `console.log` is a function. `Number()` is a function. `Boolean()` is a function. In this chapter, you will start writing your own. Functions are one of the main tools for organizing JavaScript. Without functions, programs become long lists of steps. With functions, you can break a program into smaller pieces, give those pieces names, pass information into them, and get results back. So this chapter is about writing your own. You will learn how to declare a function, call it, pass information in through parameters, and hand a result back with `return`. Along the way we cover function expressions, arrow functions, default parameters, and scope, plus one distinction beginners often blur: printing a value is not the same as returning one. The payoff is code that repeats itself less and reads more clearly.
Arrays
An array stores a list of values. So far, most variables have stored one value at a time: one name, one score, one total, one boolean. Real programs often need lists. A to-do app needs a list of tasks. A shopping cart needs a list of items. A quiz needs a list of questions. A game might need a list of players. Arrays are JavaScript's basic tool for ordered lists. You will learn how to build an array, read and update items by their position, add and remove items from either end, and loop through everything inside. From there we get to the methods that do the real work: searching with `includes` and `find`, reshaping data with `map` and `filter`, adding it all up with `reduce`, and sorting. By the last exercise, reaching for the right one of these should feel natural rather than like guesswork.
Objects
An object groups related values under property names. Arrays are good for ordered lists. Objects are good for describing one thing with several details. A user can have a name, age, email, and membership status. A task can have text, a completion state, and a priority. A product can have a name, price, and stock count. Objects are one of the most important parts of JavaScript because they let you model real information. They earn that importance because they let you model real information. This chapter starts with object literals, properties, and the two ways to read them: dot notation and bracket notation. From there it moves through adding and deleting properties, writing methods, and the `this` keyword, then on to nested objects, arrays of objects, looping over properties, destructuring, and spread. Put together, these let you describe one real-world thing and then update or combine it however the program needs.
Strings in Depth
Strings store text, but text work is rarely just "show this message." Programs receive names, emails, search terms, filenames, passwords, comments, CSV rows, URLs, IDs, and API responses as strings. Those strings may have extra spaces, inconsistent capitalization, missing pieces, or patterns you need to find. JavaScript gives you many tools for working with text. You can measure strings, clean them, search them, extract parts, split them into arrays, join arrays back into strings, build messages with template literals, and use regular expressions for pattern matching. This chapter goes deeper into strings so you can handle text in practical programs. Work through it and you will be able to clean up user input, search and pull pieces out of text, build readable messages, split and rejoin simple formats, and use small regular expressions without treating them as magic.
Project: Build a To-Do List (Console Edition)
This chapter is your first project chapter. The goal is not to build a beautiful app yet. There is no browser interface, no buttons, no CSS, and no saved file. The goal is to practice the core logic of a small program using the tools you have already learned: values, variables, data types, operators, decisions, loops, functions, arrays, objects, and strings. You will build a console to-do list that can add tasks, complete tasks, delete tasks, rename tasks, count incomplete tasks, show different task views, reject bad input, and run a small test section at the bottom of the file. The app stores tasks in memory. That means the list resets every time the program ends. That is fine for this chapter. Persistence comes later. The real lesson is how to turn a small idea into data, functions, and a handful of test calls.