Exercises
Objectives
By the end of this lesson, you should be able to:
- Explain the core concepts from this module in your own words
- Write and run a small Node.js program from the command line
- Connect the request-response lifecycle to a concrete example
⚠️ A note on verification: every command and output in the practical exercises was actually run with Node.js.
Exercise 1: Frontend, Backend, and Client-Server
a) In your own words, explain the difference between frontend and backend development.
b) A shopping app shows a “10% off” banner for logged-in users only. Is deciding “is this user logged in, and are they eligible for this discount” a frontend or backend responsibility? Explain why.
c) Explain, in your own words, what makes a program a “client” versus a “server” in a given interaction, referring to roles rather than specific hardware.
d) Explain why a single physical machine could, in principle, run both a client and a server program at the same time.
Exercise 2: HTTP and the Request-Response Lifecycle
a) Identify the method, path, and one header in this request: GET /users/17 HTTP/1.1 with header Accept: application/json.
b) Explain, in your own words, what HTTPS adds on top of plain HTTP, and give one concrete reason it matters.
c) List the seven steps of the request-response lifecycle from Lesson 4, in order, from memory.
d) For the URL https://shop.example.com/cart, identify which step of the lifecycle is responsible for translating shop.example.com into an IP address.
Exercise 3: Static vs Dynamic, APIs, REST vs GraphQL
a) A company’s “About Us” page never changes based on who’s viewing it. A company’s “My Orders” page shows different content for every logged-in user. Identify which is static and which is dynamic, and explain why.
b) Explain, in your own words, the difference between a website and a web service.
c) Explain the core difference in how a client requests data under REST versus GraphQL.
d) Give an example of “over-fetching” under a REST API, and explain how GraphQL is designed to avoid it.
Exercise 4: Your First Node.js Programs
a) Write a file profile.js that declares a name, a role, and years of experience as variables, then logs a sentence combining all three using a template literal. Expected output (with your own values): Erin Castillo is a Backend Developer with 3 years of experience.
b) Write a file argsum.js that reads two numbers from the command line (via process.argv), converts them from strings to numbers, and logs their sum. Running node argsum.js 15 27 should print 15 + 27 = 42.
c) Run node --version and npm --version on your own machine, and confirm both print a version number.
d) Explain, in your own words, why process.argv entries need to be converted with Number() before they can be added together correctly.
Recap
This module covered the real foundations backend development sits on: what backend development actually is, client-server architecture, HTTP and HTTPS, the full request-response lifecycle, static versus dynamic sites, APIs and web services, a preview of REST versus GraphQL, and a working Node.js and VS Code setup, ending with your first real Node.js programs.
Next module: modern JavaScript, the exact syntax and patterns real Node.js code, and the rest of this course, is built from.