Web Development Articles

Page 134 of 801

How To Change Text Inside All HTML Tags Using JavaScript

Yaswanth Varma
Yaswanth Varma
Updated on 15-Mar-2026 1K+ Views

In this article, we are going to perform the task of changing text inside all HTML tags using JavaScript. Let's dive into the article to learn more about changing text within all HTML, but first, let's define HTML tags. What are HTML Tags An HTML tag is a segment of markup language used to denote the start and end of an HTML element in an HTML document. HTML tags, which are a component of an HTML element, assist web browsers in turning HTML documents into web pages. For getting better understanding on changing text inside all HTML ...

Read More

How to conditionally add a member to an object using JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 3K+ Views

Objects are fundamental data structures in JavaScript, and developers often need to add properties conditionally based on certain criteria. For example, adding a "drivingLicense" property to a person object only if they are 18 or older. Here, we will explore different approaches to conditionally add members to JavaScript objects. Using the Spread Operator The spread operator provides an elegant way to conditionally add properties during object creation or update. Syntax let obj = { ...(condition ? { prop: 'value' } : {}) } If the condition is true, it ...

Read More

How to Show Today\'s Year And Random 4Digit Numbers at the Same Time?

Yaswanth Varma
Yaswanth Varma
Updated on 15-Mar-2026 237 Views

Let's see "How to show the current year and a random 4-digit number at the same time." This can be useful for creating unique identifiers, tracking dates, or displaying dynamic content. By using JavaScript's built-in Date and Math objects, you can easily implement this functionality. Let's explore different approaches to display today's year and a random 4-digit number simultaneously. Using Math.random() Method The Math.random() method returns a floating-point number between 0 (inclusive) and 1 (exclusive). We can scale this to generate 4-digit numbers. Syntax Math.random() Example In this example, we use ...

Read More

JavaScript Program to Count Inversions of size three in a given array

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 273 Views

In this tutorial, we will learn to count inversions of size three in a given array. An inversion of size three is a triplet of indices (i, j, k) where i < j < k but arr[i] > arr[j] > arr[k]. Problem Statement: Given an array of length n containing different numeric entries, we need to find the total number of triplets (i, j, k) such that arr[i] > arr[j] > arr[k], where i < j < k. We'll explore two approaches: a brute force method and an optimized solution using nested loops. Using the Brute Force ...

Read More

JavaScript Program to Count Rotations Divisible by 4

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 308 Views

In this tutorial, we will learn to count the total number of rotations divisible by 4 for the given number. Problem statement − We have given a number value. We need to rotate numbers in clockwise or anti-clockwise directions and count the total number of rotations divisible by 4. Here, we will learn two different approaches to counting rotations divisible by 4. Understanding Number Rotation When we rotate a number, we move digits from one position to another. For example, rotating 1234 clockwise gives us: 4123, 3412, 2341, and back to 1234. Each rotation creates a ...

Read More

JavaScript Program to Count Rotations Divisible by 8

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 287 Views

In this tutorial, we'll learn how to count the number of rotations of a given number that are divisible by 8. A rotation means moving digits from one end to another - for example, rotating 123 gives us 231, 312, and back to 123. We'll explore two different approaches: the straightforward rotation method and an optimized approach using divisibility rules. Understanding Number Rotation When we rotate a number, we take the last digit and move it to the front. For example, rotating 1234 gives us these possibilities: 1234 (original) 4123 (moved 4 to front) 3412 (moved ...

Read More

JavaScript Program to check idempotent matrix

Prabhdeep Singh
Prabhdeep Singh
Updated on 15-Mar-2026 240 Views

An idempotent matrix is a square matrix that has the same number of rows and columns and when we multiply the matrix by itself the result will be equal to the same matrix. We will be given a matrix and we have to find that whether it is an idempotent matrix or not. Mathematical Definition If the given matrix is M, then for M to be an idempotent matrix it should follow the property: M * M = M Matrix Multiplication Overview Multiplication of a matrix with another matrix produces another matrix and ...

Read More

How To Modify This JavaScript Code To Grab An Image URL From A JSON File, And Display It In HTML?

Yaswanth Varma
Yaswanth Varma
Updated on 15-Mar-2026 10K+ Views

This can be done by using the JavaScript method JSON.parse() to parse through the JSON file and extract the URL of the desired image. Then, an HTML img tag can be created with a source attribute set to this URL. Finally, this img tag can be appended to an existing HTML element in order to display it on your page. This will require some knowledge of basic JavaScript syntax, as well as familiarity with how JSON is structured and parsed within it. With these skills in hand, you should have no trouble modifying your code to achieve your goal! ...

Read More

JavaScript Program to Check If a Singly Linked List is Palindrome

Prabhdeep Singh
Prabhdeep Singh
Updated on 15-Mar-2026 380 Views

A singly linked list is a linear data structure that is stored in a non-contiguous way in the memory and each block is connected by holding the address of the next block also known as a node. A palindrome can be explained as a set of characters, digits, etc, and it reads the same from both the front and backside. We will be given a singly linked list and have to find whether the values stored at the nodes are equal from both the front and backside. Problem Examples Input 1 -> 2 -> 3 -> 3 ...

Read More

JavaScript Program for Ceiling in a sorted array

Prabhdeep Singh
Prabhdeep Singh
Updated on 15-Mar-2026 285 Views

An array is a linear data structure that contains objects, and in a sorted array, elements are arranged in increasing order. Given a sorted array and an integer x, we need to find the ceiling of x. The ceiling is the smallest element in the array that is greater than or equal to x. If no such element exists, we return that the ceiling does not exist. Problem Understanding Let's understand this with examples: Example 1 Array = [1, 3, 5, 7, 9] X = 19 Output: Ceiling does not exist (no element ≥ ...

Read More
Showing 1331–1340 of 8,010 articles
« Prev 1 132 133 134 135 136 801 Next »
Advertisements