Showing posts with label Js Projects. Show all posts
Showing posts with label Js Projects. Show all posts

Saturday, 17 June 2023

How to Make a Bulb Effect Using JavaScript || JavaScript Projects


   
              <!DOCTYPE html>
             <html lang="en">

            <head>
            <meta charset="UTF-8">
            <meta http-equiv="X-UA-Compatible" content="IE=edge">
            <meta name="viewport" content="width=device-width, initial-scale=1.0">
            <title>light-blub </title>
   
            </head>

            <body>
   
            <button id="turnon" onclick="document.getElementById('bulb')
           .src='/light-blub/img/on-bulb.jpg' ">Turn on</button>
            <img id="bulb" src="/light-blub/img/off-bulb.jpg" alt="" class="center">
            <button id="turnoff"  onclick="document.getElementById('bulb')
            .src = '/light-blub/img/off-bulb.jpg' ">Turn Off</button>
            </body>
            </html>


Tuesday, 6 June 2023

3 Fun JavaScript Programs to Level Up Your Coding Skills || JS Projects

 

Sure! Here's an article featuring 3 JavaScript programs with code examples:

Title: 3 Fun JavaScript Programs to Level Up Your Coding Skills

Introduction:

JavaScript is a versatile programming language that can be used to build interactive web applications. If you're looking to sharpen your coding skills and have some fun along the way, here are 3 JavaScript programs that you can try out. Each program includes code examples to help you understand the implementation. Let's dive in!

  1. Number Guessing Game: The number guessing game is a classic program that challenges the user to guess a random number within a specified range. Here's an example implementation in JavaScript:

    
     let randomNumber = Math.floor(Math.random() * 100) + 1;
    let guessedNumber = prompt("Guess a number between 1 and 100:");

       if (guessedNumber == randomNumber) {
      console.log("Congratulations! You guessed the correct number.");
    } else {
      console.log("Oops! Better luck next time. The number was: "
       + randomNumber);
    }



  1. TODO List: Create a simple TODO list application that allows users to add and remove tasks. Here's an example implementation: 

             
                let todoList = [];
                   function addTask(task) {
                  todoList.push(task);
                }
                function removeTask(task) {
                  let index = todoList.indexOf(task);
                  if (index > -1) {
                    todoList.splice(index, 1);
                  }
                }

                addTask("Buy groceries");
                addTask("Finish homework");
                removeTask("Buy groceries");

                console.log(todoList);
                 // Output: ["Finish homework"]


  1. Palindrome Checker: A palindrome is a word, phrase, number, or other sequence of characters that reads the same forward and backward. Check if a given word is a palindrome using JavaScript:

       
       function isPalindrome(word) {
         let reversedWord = word.split("").reverse().join("");
        return word === reversedWord;
      }

      console.log(isPalindrome("racecar")); // Output: true
      console.log(isPalindrome("hello")); // Output: false


Thanks for Visting Here ,.

This is me