Choose matching records
Use filter to keep phones that are in stock, then map those records to model names.
Practise turning arrays of objects into useful results. These six beginner exercises use phones, carts, books, tags and orders to make filtering, sorting, counting and string handling easier to understand.
Start with arrays, object properties, booleans and basic arithmetic. An arrow-function callback is useful, but a for...of loop can help you understand the steps first.
Use filter to keep phones that are in stock, then map those records to model names.
Multiply each cart item’s price by quantity, then accumulate the amounts with a loop or reduce. Count orders by status with the same technique.
Copy an array before sorting it and use a numeric comparator, so the original order stays intact and 1000 does not sort before 200.
Remove duplicates with a Set and turn a lowercase title into Title Case with split, map and join.
Use filter() to keep only phones where inStock is true. Print their model names with map().
Open lesson and hintsCalculate price × quantity for each item and add the amounts. Try a for...of loop first, then reduce().
Open lesson and hintsUse a Set to remove duplicate tags while keeping the order in which each tag first appears. Print the unique tags on one line, separated by a comma and a space.
Open lesson and hintsSort the books from cheapest to most expensive without changing the original array. Print the titles on one line, then print the title of the first item in the original array to prove it did not move.
Open lesson and hintsUse reduce to build an object that counts how many orders have each status. Print the paid, pending and shipped counts separated by spaces.
Open lesson and hintsTurn a lowercase title into Title Case. Split it into words, capitalize the first letter of each word, join the words again and print the result.
Open lesson and hintsPredict the expected result, run a small attempt, then reveal a hint only if needed. Compare the values rather than console formatting. After the walkthrough, try an empty array and explain why the result makes sense.
These exercises run in the browser JavaScript playground. They are for snippets rather than a Node.js server or an npm project.
Completion is self-reported. There is no automated grading, and progress is saved only on this device.