3. Modern JavaScript Fundamentals
Practice Lab: Responsive UI & JavaScript Drills
Practice building responsive CSS Grid layouts, filtering cart arrays with .filter() and .reduce(), and building a live DOM character counter.
- Build a self-adapting responsive card grid using CSS Grid
- Write JavaScript .filter() and .reduce() calculations on structured objects
- Connect live input events to DOM feedback safely with addEventListener
Reading syntax builds understanding—writing working code from partial starters locks it in. Complete all three browser drills below right inside the page before advancing to Browser Storage and APIs.
Use console.log(...) inside JavaScript drills to inspect intermediate array values, and check the Live Browser Preview pane on Web drills immediately after clicking Run & Preview.
Drill 1: Build a Self-Adapting Skill Grid
Update the empty .grid selector below using CSS Grid (display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px;) so the four skill cards arrange cleanly in columns and wrap automatically on narrow screens.
Drill 2: Calculate Discounted In-Stock Cart Total
Write the JavaScript chain that skips items where inStock === false, multiplies each remaining item's price by 0.9 (10% discount), sums them with .reduce(), and prints "27.00".
Click “Run Code” to execute this snippet right in your browser.
Drill 3: Live Tweet Character Counter in the DOM
Add an "input" event listener on #bio so #count updates live ("X / 120 characters") as you type, and turns red if length > 120.