Found 10711 Articles for Web Development

JavaScript Program to Find a triplet such that sum of two equals to third element

AmitDiwan
Updated on 13-Mar-2023 16:47:59

185 Views

We will be writing a JavaScript program that finds a triplet where the sum of two elements equals the third element. This program will be implemented using arrays and loop structures. We will be iterating through the array and checking for each element if the sum of two elements equal to the current element. If we find such a triplet, we will immediately return it. This program will be helpful in various mathematical computations where we need to find such triplets that follow a specific rule. Approach Here is one approach to solving the problem of finding a triplet such ... Read More

JavaScript Program to Efficiently compute sums of diagonals of a matrix

AmitDiwan
Updated on 13-Mar-2023 16:44:30

232 Views

We are going to write a program in JavaScript that efficiently computes the sum of the diagonals of a matrix. To do this, we will utilize a loop structure that iterates through the matrix and adds the elements located at the positions that correspond to the diagonals. By taking advantage of the mathematical properties of a matrix, we can minimize the amount of computation required to find the sum of the diagonals. With this approach, we will be able to handle matrices of various sizes in a computationally efficient manner. Approach To compute the sum of diagonals of a ... Read More

JavaScript Program To Delete Nodes Which Have A Greater Value On Right Side

AmitDiwan
Updated on 13-Mar-2023 16:42:33

206 Views

We will be implementing a function to delete nodes in a linked list which have a greater value on their right side. The approach is to traverse the linked list from right to left and keep track of the maximum value encountered so far. For each node, we will compare its value with the maximum value and delete the node if its value is less than the maximum value. This way, all the nodes with values greater than the maximum value on their right side will be deleted. Approach The approach to delete nodes which have a greater value on ... Read More

JavaScript Program To Delete Alternate Nodes Of A Linked List

AmitDiwan
Updated on 13-Mar-2023 16:34:29

157 Views

We will be writing a JavaScript program to delete alternate nodes of a linked list. We will be utilizing a while loop to traverse the linked list while keeping a track of the current and previous node. In each iteration of the loop, we will be skipping the current node and linking the previous node directly to the next node, effectively deleting the current node from the list. This process will be repeated until all the alternate nodes have been deleted from the linked list. Approach Traverse the linked list from head to end. For every node, store ... Read More

JavaScript Program to Count triplets with sum smaller than a given value

AmitDiwan
Updated on 13-Mar-2023 16:30:56

251 Views

We will be writing a JavaScript program to count the number of triplets with a sum smaller than a given value. This problem can be solved by sorting the array and using two pointers to check for the possible combinations. Firstly, we will sort the array in ascending order and then, for each element in the array, we will use two pointers to check for the triplets with a sum less than the given value. The number of such triplets will be the count we will be keeping track of. Additionally, we will be updating the count and the pointers ... Read More

JavaScript Program to Count rotations which are divisible by 10

AmitDiwan
Updated on 13-Mar-2023 16:28:44

156 Views

We are going to write a program in JavaScript that counts the number of rotations of a given number which are divisible by 10. We will loop through the rotations of the number and check if each one is divisible by 10. If a rotation is divisible, we will increment our count. In the end, we will return the count as the result of our program. This program will be useful in various applications as it provides a simple solution to check the divisibility of a number by 10. Approach The approach to solve this problem is as follows − ... Read More

JavaScript Program to Count rotations required to sort given array in non-increasing order

AmitDiwan
Updated on 13-Mar-2023 16:24:04

96 Views

We will be writing a program to count the number of rotations required to sort an array in non-increasing order. The program will use a loop to traverse the array and keep track of the maximum element found so far. When a smaller element is found, we will increment the rotation count and update the maximum element. In the end, the rotation count will be returned as the result of the program. This program will help us efficiently sort the array and determine the number of rotations required to achieve a non-increasing order. Approach The approach to counting rotations required ... Read More

How to center the contents of an HTML table?

Asif Rahaman
Updated on 13-Mar-2023 11:25:39

2K+ Views

In HTML the tag displays the contents as a table. By default, the alignment of the contents within the HTML tables is toward the left side. In this tutorial, we will understand how to center the contents of the HTML table. Use Of The tag As the name suggests, the tag helps align the texts within any container. To center align the texts, we need to use the texts within the and the tags. However, this is not a recommended process. We should use this process only when we only have to design using HTML ... Read More

How to center a <div> using the Flexbox property of CSS?

Asif Rahaman
Updated on 13-Mar-2023 11:22:42

3K+ Views

We can center a in css using justify-content property and align-item property of flexbox. They are popular because they are responsive and easy to use. In this article, we shall learn how to center using the Flexbox properties. Use The align-items And The justify-content Property The most popular method to center the div using the flexbox is the combination of justify-content and align-items properties of flexbox. The justify-content property would center align the div horizontally. The align-items property center aligns the div vertically. If you want to center align only in one direction, i.e., either vertically ... Read More

How to center a <div> using CSS grid Property?

Asif Rahaman
Updated on 13-Mar-2023 11:15:45

18K+ Views

The CSS grid is one of the most widely used elements in CSS. This element is similar to flexbox. CSS grids are two-dimensional layout systems on the web. We can place the elements in rows, columns, or both with the help of a grid. In this article, we shall understand how to center a div using the CSS grid property only. We shall use the place-items and align-items properties to achieve the same. Use Place-items property Grid-container class sets the display property to the grid to create a grid container, and the place-items property is set to the center to ... Read More

Advertisements