Create an interactive table list of item object values from a JavaScript array.

Create a list of items within a table using JavaScript.  Data is contained within an array with object values. <!DOCTYPE html> <html> <head>    <title>Learn JavaScript</title>    <style>        table{            width:100%;        }        td:first-child{            width:10%;        }        td:last-child{            width:10%;        }        td{            border: 1px solid #ddd;        }    </style> </head> <body>    <h1>Learn JavaScript Course </h1>    <div>        <input type=”text” id=”addFriend” >        <input type=”button” … Read more

JavaScript Create Element List

The document.createElement() method in JavaScript is used to create a new HTML element with a specified tag name. The method takes a single argument, which is the tag name of the element to be created. For example, document.createElement(“div”) creates a new div element. The newly created element can be accessed and modified through the DOM … Read more

Learn To Code JavaScript Free PDF 2023 Volume 2

JavaScript Closure Explained https://youtu.be/7vyHA0aODeU A closure in JavaScript is a function that has access to variables in its parent scope, even after the parent function has returned. Closures are created when a function is defined inside another function, and the inner function retains access to the variables in the outer function’s scope. Here is an … Read more

JSON and JavaScript

JavaScript Object Notation (JSON)  JavaScript Object Notation (JSON) is a lightweight data-interchange format that is easy for humans to read and write and easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language, Standard ECMA-262 3rd Edition – December 1999. JSON is a text format that is … Read more

JavaScript Closure

JavaScript Closure Explained A closure in JavaScript is a function that has access to variables in its parent scope, even after the parent function has returned. Closures are created when a function is defined inside another function, and the inner function retains access to the variables in the outer function’s scope. Here is an example … Read more

JavaScript Coding Exercises Vol 1 2023

Sample JavaScript Code Laurence Svekis JavaScript Closure A closure in JavaScript is a function that has access to the variables in its parent scope, even after the parent function has completed execution. This allows for data to be “closed over” or remembered by the inner function, even after the outer function has returned. For example: … Read more

JavaScript Image Gallery and Dynamic Image Gallery using page classes or create page elements on the fly with code

Here is an example of a JavaScript image gallery maker that creates a simple image gallery with prev/next buttons to navigate through the images: <div id=”gallery”>   <img src=”image1.jpg” id=”current-image”>   <button id=”prev-button”>Prev</button>   <button id=”next-button”>Next</button> </div> <script>   var images = [“image1.jpg”, “image2.jpg”, “image3.jpg”, “image4.jpg”];   var currentIndex = 0;   var gallery = document.getElementById(“gallery”);   var currentImage = document.getElementById(“current-image”);   var … Read more

How to create a simple JavaScript game from scratch Lock Combo Guessing Game with source code

Lock Combo Guessing Game Dynamic number of lock slots, guess the correct combination to open the lock. When the guess is incorrect the background of the lock slot will be blue for too low and red for too high. Use the hints to select and guess the correct values for each slot. Once all the … Read more

Number Guessing Game How to Create a simple JavaScript Game from Scratch Math Random

Number Guessing Game Guess a number from within the given random, this exercise is designed to practice Math Random and use of random values in a simple number guessing game created using JavaScript Code.

Creating and working with Arrays in JS

Creating and working with Arrays in JS There are several ways to create arrays in Javascript. Also, adding new index values will update the number of items in the array.  Length can be set to update the number of items in the array.  To loop through the items in an array you can use for … Read more