LearnFrenzy
Sign in Take a free test

JavaScript Programming · Practice by type

JavaScript Programming Programs for Practice with Output

Practice programs for every JavaScript Programming topic, each with a full solution, its real output and an explanation. Try writing each one yourself first.

  • 240 questions
  • 24 topics
  • Answers checked on a real compiler

JavaScript Basics 10 questions

  1. Print a student report card in JavaScript Easy
  2. Simple interest and total amount in JavaScript Easy
  3. Celsius to Fahrenheit table in JavaScript Easy
  4. Swap two variables in JavaScript Easy
  5. Area and perimeter of a rectangle and a circle in JavaScript Easy
  6. Convert seconds to HH:MM:SS in JavaScript Medium
  7. Classify numbers as even/odd and positive/negative in JavaScript Easy
  8. Sum of digits of a number in JavaScript Medium
  9. Check leap years in JavaScript Medium
  10. Initials and username from a full name in JavaScript Medium

Variables: var, let and const 10 questions

  1. Shopping cart total with GST in JavaScript Easy
  2. A counter that keeps its own state in JavaScript Medium
  3. Multiplication table in JavaScript Easy
  4. Running average of test marks in JavaScript Easy
  5. Deep freeze a configuration object in JavaScript Hard
  6. Minimum, maximum and average temperature in JavaScript Medium
  7. First 10 Fibonacci numbers in JavaScript Easy
  8. Countdown with setTimeout in JavaScript Medium
  9. Year-by-year compound interest in JavaScript Medium
  10. Count vowels and consonants in JavaScript Easy

Data Types 10 questions

  1. Report the type of every value in an array in JavaScript Easy
  2. Exact factorial with BigInt in JavaScript Medium
  3. Exact bill total using paise in JavaScript Medium
  4. Validate numeric input strings in JavaScript Medium
  5. Deep clone vs JSON copy in JavaScript Hard
  6. Count values of each type in JavaScript Easy
  7. Decimal, binary, octal and hexadecimal table in JavaScript Easy
  8. Compare decimal results safely in JavaScript Medium
  9. Remove falsy values from an array in JavaScript Easy
  10. A precise type-of function in JavaScript Hard

Operators 10 questions

  1. Simple calculator in JavaScript Easy
  2. Even or odd with % and with bitwise AND in JavaScript Easy
  3. Swap two numbers without a third variable in JavaScript Medium
  4. Salary slip with compound assignment in JavaScript Easy
  5. Check for a power of two in JavaScript Medium
  6. Count the 1-bits of a number in JavaScript Medium
  7. Merge user settings with defaults using ?? in JavaScript Medium
  8. Reverse the digits of a number in JavaScript Easy
  9. Largest of three numbers with the ternary operator in JavaScript Easy
  10. Operator precedence quiz evaluator in JavaScript Hard

Conditional Statements 10 questions

  1. Grade and division from marks in JavaScript Easy
  2. Triangle type from three sides in JavaScript Easy
  3. Roots of a quadratic equation in JavaScript Medium
  4. Day name and type from a number with switch in JavaScript Easy
  5. Income tax with slab rates in JavaScript Hard
  6. Classify characters with switch (true) in JavaScript Medium
  7. ATM transactions with validation in JavaScript Medium
  8. Rock, paper, scissors winner in JavaScript Medium
  9. FizzBuzz in JavaScript Easy
  10. Movie ticket price with several rules in JavaScript Medium

Loops 10 questions

  1. Sum and average of even and odd numbers in JavaScript Easy
  2. Prime numbers up to 50 in JavaScript Easy
  3. Star pyramid pattern in JavaScript Easy
  4. Three-digit Armstrong numbers in JavaScript Medium
  5. GCD and LCM with Euclid's algorithm in JavaScript Medium
  6. Palindrome numbers in a range in JavaScript Medium
  7. Floyd's triangle in JavaScript Easy
  8. First repeated value in JavaScript Medium
  9. Decimal to binary with a loop in JavaScript Medium
  10. Perfect numbers up to 10,000 in JavaScript Hard

Functions 10 questions

  1. Area calculator with default parameters in JavaScript Easy
  2. Average of any number of values in JavaScript Easy
  3. compose and pipe in JavaScript Hard
  4. A function that runs only once in JavaScript Medium
  5. Memoized Fibonacci in JavaScript Hard
  6. Recursive factorial and fast power in JavaScript Easy
  7. Discount calculator factory in JavaScript Medium
  8. Apply a list of price rules with callbacks in JavaScript Medium
  9. Count how often a function is called in JavaScript Medium
  10. Password validator with helper functions in JavaScript Medium

Scope and Hoisting 10 questions

  1. Bank account with private balance in JavaScript Medium
  2. Unique ID generator in JavaScript Easy
  3. Simple rate limiter in JavaScript Hard
  4. Configurable logger with levels in JavaScript Medium
  5. Stack with private storage in JavaScript Medium
  6. Shopping cart with private items in JavaScript Medium
  7. Running average with a closure in JavaScript Easy
  8. Cycle through options with a closure in JavaScript Easy
  9. Cache with expiry using a closure in JavaScript Hard
  10. Lazy initialisation in JavaScript Medium

Arrays 10 questions

  1. Second largest element in JavaScript Medium
  2. Remove duplicates from an array in JavaScript Easy
  3. Rotate an array by k positions in JavaScript Medium
  4. Merge two sorted arrays in JavaScript Medium
  5. Transpose a matrix in JavaScript Medium
  6. Split an array into chunks in JavaScript Easy
  7. Move all zeros to the end in JavaScript Medium
  8. Find the missing number from 1 to n in JavaScript Easy
  9. Frequency of elements and the most frequent one in JavaScript Medium
  10. Pairs with a given sum (two sum) in JavaScript Hard

Strings 10 questions

  1. Palindrome check ignoring case and punctuation in JavaScript Easy
  2. First non-repeating character in JavaScript Medium
  3. Convert a sentence to title case in JavaScript Easy
  4. Check whether two words are anagrams in JavaScript Medium
  5. Longest word in a sentence in JavaScript Easy
  6. Caesar cipher encrypt and decrypt in JavaScript Medium
  7. Compress repeated characters in JavaScript Medium
  8. Mask a card number and an email address in JavaScript Easy
  9. Count words and occurrences of a word in JavaScript Medium
  10. Longest substring without repeating characters in JavaScript Hard

Objects 10 questions

  1. Group an array of objects by a key in JavaScript Medium
  2. Deep clone an object recursively in JavaScript Hard
  3. Deep equality of two objects in JavaScript Hard
  4. Invert an object's keys and values in JavaScript Easy
  5. pick and omit properties in JavaScript Medium
  6. Read a nested value by path in JavaScript Medium
  7. Total inventory value with Object.entries in JavaScript Easy
  8. Flatten a nested object to dot keys in JavaScript Hard
  9. Constructor function with a prototype method in JavaScript Medium
  10. Find the changed fields between two objects in JavaScript Medium

Array Methods 10 questions

  1. Class results with filter, map and reduce in JavaScript Easy
  2. Remove duplicate objects by id in JavaScript Medium
  3. Flatten and sum nested arrays in JavaScript Easy
  4. Implement map, filter and reduce yourself in JavaScript Hard
  5. Count occurrences with reduce in JavaScript Easy
  6. Unique long words in a sentence in JavaScript Medium
  7. Zip two arrays into an object in JavaScript Easy
  8. Partition an array into two groups in JavaScript Medium
  9. Group words by their first letter in JavaScript Medium
  10. Validate form fields with every and some in JavaScript Medium

String Methods 10 questions

  1. Create a URL slug from a title in JavaScript Easy
  2. Convert text to sentence case in JavaScript Medium
  3. Count occurrences of a substring in JavaScript Medium
  4. Validate Indian mobile numbers and PAN in JavaScript Medium
  5. Extract hashtags and mentions in JavaScript Medium
  6. A tiny template engine in JavaScript Hard
  7. Convert between camelCase and snake_case in JavaScript Medium
  8. Truncate text at a word boundary in JavaScript Easy
  9. Parse a URL query string in JavaScript Medium
  10. Highlight a search term in text in JavaScript Hard

ES6 Features 10 questions

  1. Employee and manager classes in JavaScript Medium
  2. Stack class with private fields in JavaScript Medium
  3. LRU cache with a Map in JavaScript Hard
  4. A simple event emitter in JavaScript Hard
  5. An iterable Range class in JavaScript Medium
  6. Infinite Fibonacci generator in JavaScript Medium
  7. Union, intersection and difference with Sets in JavaScript Easy
  8. Word frequency with a Map in JavaScript Easy
  9. Savings account with inheritance and a static counter in JavaScript Medium
  10. An "abstract" base class in JavaScript Medium

Arrow Functions 10 questions

  1. Rewrite utility functions as arrow functions in JavaScript Easy
  2. Curried GST calculator in JavaScript Medium
  3. Event handlers with class-field arrows in JavaScript Hard
  4. A lap timer that keeps this in callbacks in JavaScript Medium
  5. Filter and sort products with arrow functions in JavaScript Easy
  6. once and after helpers with arrow functions in JavaScript Medium
  7. Partial application with arrow functions in JavaScript Medium
  8. Calculator with a table of arrow functions in JavaScript Easy
  9. A string transformation pipeline with arrows in JavaScript Medium
  10. Grouping and counting with arrow one-liners in JavaScript Easy

Destructuring 10 questions

  1. Read weather data from an API response in JavaScript Medium
  2. A function that returns several statistics in JavaScript Easy
  3. Format addresses with destructuring defaults in JavaScript Easy
  4. Convert tuples to objects in JavaScript Easy
  5. Merge user options with defaults using destructuring in JavaScript Medium
  6. Parse CSV rows with destructuring in JavaScript Medium
  7. Simulate React's useState with destructuring in JavaScript Hard
  8. Remove sensitive fields with object rest in JavaScript Medium
  9. Swap adjacent elements with destructuring in JavaScript Easy
  10. Read deep configuration safely in JavaScript Hard

Spread and Rest Operators 10 questions

  1. Merge arrays into a unique sorted list in JavaScript Easy
  2. A variadic message formatter in JavaScript Easy
  3. Merge nested settings with spread in JavaScript Medium
  4. Immutable list updates for a to-do app in JavaScript Medium
  5. Clone and enrich records with spread in JavaScript Easy
  6. Highest and lowest values in nested arrays in JavaScript Easy
  7. Zip any number of arrays in JavaScript Medium
  8. Build a search query with conditional spread in JavaScript Medium
  9. Toggle selections immutably in JavaScript Medium
  10. A generic curry function with rest parameters in JavaScript Hard

Closures 10 questions

  1. Debounce an autosave in JavaScript Hard
  2. Throttle a function with a clock in JavaScript Hard
  3. Memoize with cache statistics in JavaScript Medium
  4. Limit login attempts with a closure in JavaScript Medium
  5. Subscriptions that return an unsubscribe function in JavaScript Medium
  6. A resettable number sequence in JavaScript Easy
  7. A function spy that records calls in JavaScript Medium
  8. A quiz scorer with private answers in JavaScript Easy
  9. A stopwatch with laps using closures in JavaScript Medium
  10. Count events in the last N seconds with a closure in JavaScript Hard

Callbacks 10 questions

  1. Retry a failing task with callbacks in JavaScript Hard
  2. Run asynchronous tasks one after another in JavaScript Medium
  3. Run tasks in parallel and keep the results in order in JavaScript Hard
  4. Report download progress with callbacks in JavaScript Easy
  5. Validation with success and failure callbacks in JavaScript Easy
  6. Give a callback task a timeout in JavaScript Hard
  7. Convert a callback API to promises in JavaScript Medium
  8. Sort with custom comparator callbacks in JavaScript Easy
  9. A countdown with onTick and onDone callbacks in JavaScript Easy
  10. An async waterfall in JavaScript Medium

Promises 10 questions

  1. A sleep helper and timed steps in JavaScript Easy
  2. Retry a promise with exponential backoff in JavaScript Hard
  3. Add a timeout to any promise in JavaScript Medium
  4. Run promise tasks in sequence in JavaScript Medium
  5. Run promises with a concurrency limit in JavaScript Hard
  6. A success/failure report with Promise.allSettled in JavaScript Medium
  7. Download from the fastest working mirror with Promise.any in JavaScript Medium
  8. Implement Promise.all yourself in JavaScript Hard
  9. Cache promises to avoid duplicate requests in JavaScript Medium
  10. Load profile data in parallel with Promise.all in JavaScript Easy

Async/Await 10 questions

  1. Retry an async operation with await in JavaScript Medium
  2. Download files sequentially and in parallel with async/await in JavaScript Easy
  3. Give an awaited call a time limit in JavaScript Medium
  4. Process a queue with limited concurrency using async/await in JavaScript Hard
  5. Load all pages of an API with an async generator in JavaScript Hard
  6. Poll a job until it is ready with async/await in JavaScript Medium
  7. Cache async results with async/await in JavaScript Medium
  8. Send bulk notifications with await and allSettled in JavaScript Easy
  9. A typing effect with await in JavaScript Easy
  10. A class with a static async factory in JavaScript Hard

Event Loop 10 questions

  1. Simulate the event loop in JavaScript Hard
  2. Process a large array in chunks without blocking in JavaScript Medium
  3. Batch DOM-style updates with microtasks in JavaScript Medium
  4. Implement setTimeout with a virtual clock in JavaScript Hard
  5. Sleep sort with setTimeout in JavaScript Easy
  6. Build an interval with recursive setTimeout in JavaScript Medium
  7. A cooperative round-robin scheduler with generators in JavaScript Hard
  8. Record the execution order of async callbacks in JavaScript Medium
  9. Drain a message queue a few items per tick in JavaScript Medium
  10. Run tasks one per event-loop turn in JavaScript Medium

DOM Manipulation 10 questions

  1. Render an array as a list in JavaScript Easy
  2. A todo list with event delegation in JavaScript Medium
  3. A sortable table in JavaScript Hard
  4. Live search that filters a list in JavaScript Medium
  5. Validate a signup form in JavaScript Medium
  6. An accessible tabs component in JavaScript Medium
  7. A live character counter in JavaScript Easy
  8. Print the DOM tree recursively in JavaScript Medium
  9. Highlight a search term safely in JavaScript Hard
  10. Components that talk through custom events in JavaScript Hard

Error Handling 10 questions

  1. Map custom errors to HTTP responses in JavaScript Medium
  2. A safe JSON parser with a fallback in JavaScript Easy
  3. Throw and handle typed errors for input in JavaScript Medium
  4. Wrap errors and print the cause chain in JavaScript Medium
  5. A Result type instead of exceptions in JavaScript Hard
  6. Wrap functions so errors are logged and defaulted in JavaScript Medium
  7. A bank transfer that rolls back on error in JavaScript Hard
  8. Serialise errors (with causes) to JSON in JavaScript Medium
  9. Guarantee resource cleanup with finally in JavaScript Medium
  10. Process a batch and report every failure in JavaScript Medium

Ready to test your Programming?

Timed online tests with instant scores and explanations.

Search LearnFrenzy

Esc

Quick links