Problems › JavaScript
JavaScript practice problems
189 short problems drawn from the sort of code people actually write — pricing, stock, orders, logs, scheduling. Each one runs in your browser; nothing to install and no account.
billing 13
- Sum the invoice line itemseasy
- Compute the late payment feeeasy
- Look up the tax rate for a regioneasy
- Prorate an annual subscription refundmedium
- Early payment discountmedium
- Total cost of a subscription planmedium
- Calculate tax on a shipping chargeeasy
- Apply credits to an invoicemedium
- How much is still owedeasy
- Payment method surchargeeasy
- Refund for partially used servicemedium
- Clamp a day into a billing termeasy
- Compute the final charge on an ordereasy
data 12
- Drop the repeatseasy
- The second highest numbereasy
- The highest so fareasy
- Totals per categorymedium
- The first repeatmedium
- The peak in each windowhard
- Interleave two listseasy
- Count the oversized gapsmedium
- The imbalance across a splitmedium
- Read a grid by columnseasy
- How many of eacheasy
- The order that sortshard
dates 8
- Is it a leap yeareasy
- How many days in this montheasy
- Count the working days in a spanmedium
- Do these two bookings clasheasy
- Say a duration the way a person wouldmedium
- Read a duration a human typedmedium
- Find the first free slot in a dayhard
- Merge overlapping bookingshard
events 12
- Do two bookings clasheasy
- How much room is lefteasy
- Which slot does this time fall intoeasy
- How many event pairs overlaphard
- How many openings in the coming weeksmedium
- What does this meeting costmedium
- Is there enough breathing room between slotshard
- How many minutes between two clock timeseasy
- How many rooms are needed at peakhard
- How far apart are two scheduled dayseasy
- How many active weekdays in a spanmedium
- How long is this event in minuteseasy
finance 12
- Simple interest earnedeasy
- Balance after yearly compoundingeasy
- Convert between currencieseasy
- Split a total into installmentshard
- Variance from budgeteasy
- Months to reach a savings targeteasy
- Profit margin in permillemedium
- How much survives a round tripmedium
- Strip VAT out of a gross priceeasy
- Price per uniteasy
- Months to clear the loanhard
- Average monthly figures for a yearmedium
games 12
- Calculate combat damageeasy
- Count league pointseasy
- Score a dice paireasy
- Count neighbouring live cellsmedium
- Look up a player levelmedium
- Who won the tic-tac-toe gamehard
- Count tournament roundseasy
- Find the longest winning streakmedium
- Find a card after drawingeasy
- Score a word by letter positionseasy
- Score dice pairshard
- Distribute candies by ratinghard
inventory 7
- Will this fit in the bayeasy
- When to reorder a parteasy
- Replay a day of stock movementsmedium
- Which parts need attention firstmedium
- What the shelf is wortheasy
- Pick an order off the shelvesmedium
- Group stock by how soon it expiresmedium
logistics 11
- What does this parcel cost to sendeasy
- When does the order actually arrivemedium
- Split a load into the fewest parcelseasy
- Which zone price applieseasy
- Which trucks are overloadedeasy
- Is the order inside the same-day windoweasy
- Is this address complete enough to shipeasy
- Cost of a planned routeeasy
- Which depot is closestmedium
- How many parcels missed the vaneasy
- Parcel discount bandmedium
machines 12
- Machine uptime per thousandeasy
- Is maintenance due yeteasy
- Total minutes the line was downmedium
- Average downtime per stopmedium
- Spares to keep for a fleeteasy
- Finished units in a shiftmedium
- How much work is still queuedhard
- Defects per thousand partseasy
- Which station has the least workhard
- Good parts per run cycleeasy
- Total hours a machine ranmedium
- How many machines are past calibrationmedium
monitoring 6
- What share of requests failedeasy
- Count log lines by levelmedium
- The longest silence between heartbeatsmedium
- The p95 of a batch of latenciesmedium
- Should the alarm go offmedium
- Decide each call against a rate limithard
network 10
- Which HTTP status family does a code belong toeasy
- Cache hit ratio in permilleeasy
- Pick the next server in round-robineasy
- Exponential backoff with a ceilingeasy
- How many pages does the result set needeasy
- Peak request burst in a sliding windowmedium
- Single-byte checksum of a payloadeasy
- Classify a latency measurementmedium
- The first missing sequence numbermedium
- How many hosts fit in a CIDR blockeasy
orders 6
- Total a basket that came off a queueeasy
- Does this basket ship freeeasy
- Split an order across warehousesmedium
- Pick the coupon worth mostmedium
- Is this status change allowedmedium
- Work out the shipping chargemedium
payments 6
- Mask a card numbereasy
- Luhn check a card numbermedium
- Charge each request only oncemedium
- Should this call be retriedmedium
- Split a bill without losing a kuruşmedium
- How much of this can still be refundedeasy
pricing 8
- Apply a promo percentageeasy
- Split a gross amount into net and VATmedium
- Price an order across volume tiersmedium
- Discount, but never below the flooreasy
- Which pack size is the best valuemedium
- Loyalty points for a basketeasy
- Format money for a receiptmedium
- Week-on-week price changeeasy
production 6
- Defects per million partseasy
- How many batches to runeasy
- How busy was the linemedium
- Find the bottleneckmedium
- Overall equipment effectivenessmedium
- How long to clear the order bookmedium
reporting 6
- Running balance down a statementeasy
- The best selling products this weekmedium
- Average spend per categorymedium
- The middle of a set of readingsmedium
- Bucket some readingsmedium
- Which month grew the mostmedium
scheduling 10
- Do these two shifts overlapeasy
- How many breaks does the shift needeasy
- Total minutes scheduledeasy
- How many slots are understaffedeasy
- Rest-period violations in the hand-offseasy
- Labour cost for the rostermedium
- How many people try to book the same slotmedium
- Largest uncovered stretch of the daymedium
- Most people on the floor at oncemedium
- Extra pay for overnight hourshard
text 10
- Tidy up pasted texteasy
- Turn a product title into a URL slugmedium
- Hide most of an email addresseasy
- Cut a description to lengthmedium
- Count the words that mattermedium
- Title-case a headingmedium
- Split one CSV line properlyhard
- Wrap text to a label widthhard
- Evaluate a formulahard
- Longest stretch with no repeathard
validation 7
- Which required fields are missingmedium
- Score a passwordmedium
- Keep a value inside its rangeeasy
- Read a quantity someone typedeasy
- Normalise a phone numbermedium
- Verify a barcodemedium
- Compare two version stringshard
warmup 15
- Factorialeasy
- Nth Fibonacci numbereasy
- Sum of digitseasy
- Palindrome checkeasy
- Initials for an avatareasy
- Greatest common divisoreasy
- Reverse the order of the wordseasy
- Are these two an anagrammedium
- Write a number in Roman numeralsmedium
- Steps to reach oneeasy
- Find a value in a sorted listmedium
- Break a list into fixed-size piecesmedium
- Rotate a listmedium
- Find the two that add upmedium
- Count the set bitseasy