THE PRACTICE LIBRARY
JavaScript string practice and coding challenges
Practice JavaScript strings, arrays, and objects with browser-based challenges, visible tests, and optional hints. Start by cleaning a search query.
No account needed. Progress and drafts are saved on this device.
Start with strings: clean a search query
Search boxes receive pasted text, extra spaces, tabs, and mixed capitalization. Practice turning those different inputs into one consistent string. Check empty text and whitespace-only input as well as ordinary words. JavaScript strings are immutable, so return the transformed value.
The problem
A search box receives a string query. Return a lowercase string with leading and trailing whitespace removed and every internal run of whitespace replaced by one ordinary space. Tabs and newlines count as whitespace. Preserve punctuation and accented letters apart from normal JavaScript lowercasing. A query containing only whitespace becomes an empty string. The input is always a string.
" JavaScript Array Methods "Expected result"javascript array methods"Write your answer in the editor, then choose Run tests. Each check shows what was expected and what your code returned. Reveal hints one at a time; the solution stays behind the solution button.
Open clean a search queryJavaScript challenges
Deduplicate issue labels
Given an array of strings, return the issue labels after trimming their edges, dropping empty labels, and removing case-insensitive duplicates.
Arrays · Sets · Normalization
Validate a team handle
Validate a proposed team handle and return {valid, reason}.
Validation · Conditionals · Strings
Split a notification inbox
Given notifications with an id string and a read boolean, return {unreadIds: [...], readIds: [...]}.
Arrays · Objects · Conditionals
Group a support queue
Given tickets with an id string and status string, return an array of {status, ids} groups.
Maps · Grouping · Ordering
Update a cart without mutation
Given an items array with unique sku strings and positive integer quantity fields, update the item matching sku.
Immutability · Arrays · Object copying
Build reliable pagination
Return {items, page, totalPages, hasNext} for a requested page of a results array.
Array slicing · Boundary conditions · Pagination
Parse a settings export
Parse an array of settings lines into [{key, value}, ...].
Parsing · Maps · Strings
Merge calendar busy windows
A calendar export contains unsorted busy windows [start, end], measured in integer minutes, with start < end.
Intervals · Sorting · Immutability
Rank a command palette
Given command objects {id, title} and a query string, return matching ids for a command palette.
Filtering · Sorting · Stable ordering
Plan a dependency build
Given modules [{id, deps}], return {order, blocked}.
Graphs · Dependency ordering · Cycle detection · Sets
Find the busiest event window
Given unsorted nonnegative integer event timestamps and a positive integer windowMs, find the busiest fixed-length time window.
Sliding windows · Sorting · Boundary conditions · Data analysis