Open links in new tab
  1. Practicing JavaScript with small, focused examples is a great way to improve your skills. Below are some sample codes covering basic to intermediate concepts.

    1. Print "Hello, World!"

    console.log("Hello, World!");
    Copied!

    2. Add Two Numbers

    function addNumbers(a, b) {
    return a + b;
    }
    console.log(addNumbers(5, 10)); // Output: 15
    Copied!

    3. Check if a Number is Even or Odd

    function checkEvenOdd(num) {
    if (num % 2 === 0) {
    console.log(`${num} is Even`);
    } else {
    console.log(`${num} is Odd`);
    }
    }
    checkEvenOdd(7); // Output: 7 is Odd
    Copied!

    4. Reverse a String

    function reverseString(str) {
    return str.split("").reverse().join("");
    }
    console.log(reverseString("JavaScript")); // Output: tpircSavaJ
    Copied!

    5. Find the Largest Number in an Array

    function findLargest(arr) {
    return Math.max(...arr);
    }
    console.log(findLargest([10, 20, 30, 40])); // Output: 40
    Copied!

    6. Generate a Random Number Between Two Values

    function getRandom(min, max) {
    return Math.floor(Math.random() * (max - min + 1)) + min;
    }
    console.log(getRandom(1, 100)); // Output: Random number between 1 and 100
    Copied!
    Feedback
  1. JavaScript Practice Hub (2026) – Exercises & Quizzes by Topic

    Practice JavaScript with topic-wise exercises and quizzes. Covers variables, data types, operators, loops, strings, functions, and more. Free and beginner-friendly.

  2. JavaScript - Exercises, Practice, Solution - w3resource

    Mar 7, 2025 · This resource offers a total of 4905 JavaScript problems for practice. It includes 1041 main exercises, each accompanied by solutions, detailed explanations, and three/four related problems.

  3. Free Javascript challenges online | JSchallenger

    JSchallenger offers a variety of Javascript exercises, lessons, and quizzes for all levels and topics. You can type and execute code, track your progress, and join …

  4. JavaScript Exercises, Practice Questions and Solutions

    Sep 24, 2025 · In this section, we’ll divide into different JavaScript topics like strings, arrays, numbers, objects, and more. Each topic comes with hands-on …

  5. JavaScript Coding Challenges - Practice and Improve | JavaScript ...

    Challenge yourself with our collection of JavaScript coding problems. From beginner to advanced levels, practice algorithms, data structures, and problem-solving skills.

  6. People also ask
    Loading
    Unable to load answer
  7. 2,500+ JavaScript Practice Challenges // Edabit

    Practice JavaScript coding with fun, bite-sized exercises. Earn XP, unlock achievements and level up. It's like Duolingo for learning to code.

  8. JavaScript Exercises | JavaScript Challenges | LabEx

    This page provides a collection of hands-on JavaScript exercises designed to solidify understanding of the language. Apply your knowledge by solving …

  9. JavaScript exercises on Exercism

    Practice JavaScript objects by tracking high scores of an arcade game. Dive deeper into JavaScript functions while preparing to cook the perfect lasagna. Learn how …

  10. JavaScript Practice Questions and Coding Exercises for …

    Explore 100 JavaScript practice questions, coding problems, and online exercises with solutions. Ideal for beginners to strengthen core JavaScript skills.