Bhavya B. Popat
also known as BhavyaJustChill
|
Bhavya B. Popat
also known as BhavyaJustChill
|
Blog Post

JavaScript Exercises

17/4/2026by admin
JavaScript Exercises

If you are a beginner who wants to become Full Stack Developer in future, there is no doubt that fastest way to get there is by mastering JavaScript. This flexible language which started as client side scripting language for browsers has evolved over time and become so advanced that now it runs pretty much anywhere, be it Servers (through Node.js), in browsers (V8 engine), or even mobile (React Native). So here are the exercises That I havecurated for absolute beginners!

List of JavaScript Exercises as beginner

  • Fibonacci Sequence Generator: Write an arrow function that generates the first n numbers in the Fibonacci sequence.
  • Array Filtering: Create an arrow function that takes an array of numbers and returns a new array containing only the even numbers.
  • String Capitalizer: Implement an arrow function that capitalizes the first letter of each word in a given string.
  • Variable Scope Demonstration: Demonstrate the difference between var, let, and const by writing a function that declares variables using each keyword within different scopes (e.g., inside a loop or conditional).
  • Immutable Object Creation: Use const to create an object and attempt to modify its properties. Explain the behavior.
  • Personalized Greeting: Write a function that takes a user's name and age and returns a personalized greeting message using template literals.
  • HTML Snippet Generator: Create a function that generates a simple HTML card component as a string using template literals. The card should include a title, image URL, and description.
  • Object Destructuring: Given an object representing a book with properties like title, author, year, and genre, use destructuring to extract these properties into separate variables.
  • Array Destructuring: Write a function that takes an array of user information [firstName, lastName, email] and uses destructuring to assign each element to a corresponding variable.
  • Merging Arrays: Use the spread operator to merge two arrays into one.
  • Function Argument Collector: Create a function that accepts any number of numerical arguments and returns their sum using the rest operator.
  • Class Creation: Define a Person class with properties name and age, and a method greet() that returns a greeting message.
  • Inheritance Implementation: Create a Student class that inherits from the Person class and adds an additional property grade. Override the greet() method to include the student's grade in the message.
  • Module Export and Import: Create two JavaScript files where one file exports a function and the other imports and uses that function.
  • Named vs. Default Exports: Demonstrate the difference between named and default exports by creating examples of each and showing how to import them.
  • Basic Promise: Write a function that returns a promise which resolves after 2 seconds with a message "Promise Resolved!".
  • Fetching Data with Promises: Create a function that fetches data from a public API (e.g., JSONPlaceholder) using fetch and handles the response with .then() and .catch().
  • Async/Await Implementation: Rewrite the previous exercise using async/await syntax instead of .then() and .catch().
  • Custom Iterator: Implement a custom iterator for an object that allows iterating over its properties using a for...of loop.
  • Generator Function: Write a generator function that yields the first n prime numbers.
  • Find and Filter: Given an array of user objects, write a function to find a user by their ID and another function to filter users based on a specific criteria (e.g., age greater than 30).
  • Reduce to Compute Totals: Use the reduce method to calculate the total price of items in a shopping cart array.
  • Try/Catch Implementation: Write a function that attempts to parse a JSON string and uses try/catch to handle any potential errors gracefully.
  • API Data Retrieval: Use any library (like axios) or the built-in fetch() to call an API and retrieve data.
At the end I just want to say that just knowing about these exercises won't be benificial unless you perform them on your own and not use AI, because knowing the basics is what distincts you from the AI otherwise you may get stuck in future solving problems yourself!
Tags: javascriptexercisestutorialbeginners