JavaScript ยท Practice
JavaScript exercises
20 exercises: 5 easy, 8 medium and 7 hard. Each has a starter file, examples, hints and a solution you can reveal, and your program is checked against every test case. Everything runs in your browser.
- Cafe bill totalEasy
Read prices and quantities, then print a JavaScript cafe bill total with exactly two decimal places.
BasicsNot started
- Cold-room alertEasy
Classify a sensor reading with JavaScript if, else if and exact boundary handling.
ConditionsNot started
- Deduplicate article tagsEasy
Remove repeated tags while preserving first-seen order using JavaScript arrays and includes.
ArraysNot started
- Headline to URL slugEasy
Normalise a simple headline into a lowercase hyphenated URL slug with JavaScript string methods.
StringsNot started
- Shipping fee functionEasy
Write and call a JavaScript function that calculates shipping from weight and distance.
FunctionsNot started
- Dispatch code normalizerMedium
Normalize and deduplicate dispatch codes with mixed case and formatting hyphens.
StringsNot started
- First repeated ticketMedium
Find the first ticket ID whose second appearance occurs earliest in a scan log.
ArraysNot started
- Longest open runMedium
Scan a status string and find its longest consecutive open period with a JavaScript loop.
LoopsNot started
- Merge shift hoursMedium
Merge two shift-hour exports by employee without losing repeated records or zero-hour entries.
ObjectsNot started
- Priority ticket orderMedium
Sort support tickets by descending priority with an alphabetical ID tie-break.
ArraysNot started
- Ticket code countsMedium
Count repeated support codes with a JavaScript object and print a sorted frequency report.
ObjectsNot started
- Validated score averageMedium
Calculate an average from whole-number scores while accounting for malformed and out-of-range tokens.
Error HandlingNot started
- Warehouse movement tallyMedium
Aggregate warehouse movements by item and print sorted totals with a JavaScript object.
ObjectsNot started
- Best revenue windowHard
Find the earliest maximum-revenue stretch of fixed length using an O(N) sliding window.
ArraysNot started
- Invoice discount in centsHard
Calculate integer-cent invoice discounts with a cap and explicit threshold boundaries.
FunctionsNot started
- Pallet pair under limitHard
Choose the heaviest pair of distinct pallets under a weight limit with deterministic tie-breaking.
ArraysNot started
- Peak staffing windowHard
Find the earliest minute with maximum overlapping shifts using a sweep over start and end events.
ArraysNot started
- Refund ledger auditHard
Reconcile partial refunds against orders while rejecting unknown and over-refund entries.
ObjectsNot started
- Seat inventory eventsHard
Apply signed seat changes per venue while rejecting events that would breach capacity or go negative.
ObjectsNot started
- Unique parcel registerHard
Accept well-formed unique parcel records while rejecting duplicate IDs and invalid quantities.
Error HandlingNot started