1. Basic Syntax Structure of a JavaScript Program: // Inline comment /* Multi-line comment */ console.log(“Hello, World!”); // Output to console 2. Variables Declaration: var name = “John”; // Global …
javascript
-
-
In this article we show a simple way to convert a decimal number to a binary number using JavaScript Example 1 The user is prompted to enter a number. The …
-
In this example we display all the prime numbers between 1 and 100. A prime number is a positive integer that is only divisible by 1 and itself Example // …
-
In this example we check if a year is a leap year Some examples use a formula to check if a year is a leap year, this example checks if …
-
In this example we will display the current date and time in JavaScript Example 1 // get local machine date time const date = new Date(); // get the date …
-
In this example we will check that two strings match You will see that the pattern below has the following gi, this means Flags Description g Performs a global match …
-
In this example we will compare 2 strings to see if they are a match Example 1 First of all we convert the strings to lowercase using .toLowerCase() method, you …
-
In this example we will replace a string in another string using JavaScript This time will use regular expressions We will define a string, then we will define t he …
-
In this example we show you how to generate random strings in JavaScript Example 1 We will define a list of characters which will include lower and upper case A …
-
In this example we will show you how to generate a multiplication table Example 1 We take the user input and store in the constant number We then use a …