Articles on Trending Technologies

Technical articles with clear explanations and examples

JavaScript Program to Find median in row wise sorted matrix

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 239 Views

We will be describing the process of finding the median in a row-wise sorted matrix using JavaScript. First, we will traverse the matrix to gather all the elements into a single array. Then, we will sort the array to find the middle value, which will be our median. In case of an even number of elements, the median will be the average of the two middle values. Approach 1: Simple Array Concatenation Method Given a row-wise sorted matrix, the median can be found by the following approach − Combine all rows into a ...

Read More

How To Password Protect A Page Using Only HTML, CSS And JavaScript?

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

To password protect a page using only HTML, CSS and JavaScript, is an important security measure for webpages that contain sensitive information or require authentication for access. In this article, we will understand how to create a simple form that requires users to enter a password before they can view the content of your protected page. Note: Client-side password protection provides basic content hiding but is not secure for truly sensitive data. For real security, use server-side authentication. Approaches to Password Protect a Page Here are two approaches to password protect a page using only HTML, CSS ...

Read More

JavaScript Program to Find Mth element after K Right Rotations of an Array

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 195 Views

We are writing a JavaScript program to find the mth element after k right rotations of an array. Instead of actually rotating the array, we can calculate the final position mathematically for optimal performance. Understanding Right Rotations In a right rotation, elements move to the right, and the last element wraps around to the first position. For example, rotating [1, 2, 3, 4, 5] right by 2 positions gives [4, 5, 1, 2, 3]. Mathematical Approach The key insight is that we don't need to perform actual rotations. We can calculate where the mth element will ...

Read More

JavaScript Program to Find Perimeter of a Triangle

Disha Verma
Disha Verma
Updated on 15-Mar-2026 1K+ Views

The perimeter of a triangle is the sum of the lengths of its three sides. You can find the perimeter of a triangle using JavaScript by calculating the sum of all sides, where perimeter = a + b + c. To find the perimeter of a triangle using JavaScript, we need to write a function that adds the three side lengths together. In this article, we will understand the perimeter formula and implement practical examples. Understanding the Perimeter Formula The formula for the perimeter of a triangle is straightforward. The perimeter equals the sum of all three ...

Read More

JavaScript Program to Find Simple Interest

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 9K+ Views

To find simple interest in JavaScript, we calculate the product of principal amount, rate of interest (%), and time period. Simple interest is a quick and easy method to find the interest charge or extra amount paid by a borrower to a lender on a certain amount of principal within a time period. In this article, we are given data for principal, rate, and time. Our task is to write a JavaScript program to find simple interest. Users should be familiar with the formula to calculate simple interest, arithmetic operators in JavaScript, and JavaScript functions. Formula ...

Read More

JavaScript Program to Find the Longest Bitonic Subsequence | DP-15

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 494 Views

We will be finding the longest bitonic subsequence in an array using dynamic programming. A bitonic subsequence is a sequence which is first increasing, then decreasing. To find the longest bitonic subsequence, we will use a two-step approach: first find the longest increasing subsequence ending at each position, then find the longest decreasing subsequence starting from each position. What is a Bitonic Subsequence? A bitonic subsequence has two parts: Increasing part: Elements are in ascending order Decreasing part: Elements are in descending order For example, in [1, ...

Read More

JavaScript Program to Find the subarray with least average

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 258 Views

We are going to write a program that will find the subarray with the least average. To do this, we will iterate through the array and keep track of the current subarray and its sum. For each element, we will calculate the average of the current subarray and compare it with the minimum average we have seen so far. If it is lower, we will update the minimum average and the start and end indices of the subarray. At the end of the iteration, we will return the subarray with the least average. Approach To find the subarray ...

Read More

JavaScript Program to Form coils in a matrix

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 304 Views

We will be using JavaScript to form coils in a matrix. The process involves manipulating the elements of the matrix to create a spiral pattern. This can be achieved by changing the direction of traversal, keeping track of the visited elements, and adjusting the indices accordingly. Approach One approach to form coils in a matrix using JavaScript would be the following − Define the size of the matrix. Initialize the matrix with zeros. Use nested loops to traverse the matrix and change the values of specific cells ...

Read More

How to Get Value of Selected Radio Button Using JavaScript?

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

Getting the value of a selected radio button using JavaScript is essential for forms, surveys, quizzes, and dynamic UI updates. This article demonstrates two reliable approaches to retrieve radio button values programmatically. We'll explore how to get the selected radio button value from a group of radio buttons using the checked property and the FormData constructor. Approaches to Get Value of Selected Radio Button Here are the two main approaches to get the value of a selected radio button using ...

Read More

JavaScript Program to Generate a matrix having sum of secondary diagonal equal to a perfect square

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 304 Views

We will write a JavaScript program that generates a matrix with the sum of the secondary diagonal being a perfect square. Our program will use nested loops to traverse the matrix and calculate the sum of the secondary diagonal elements. We will then use the Math.sqrt() method to find the square root of the sum and check if it is a whole number. If it is, we will consider the sum to be a perfect square. Understanding Secondary Diagonal The secondary diagonal (also called anti-diagonal) consists of elements from the top-right to bottom-left corner. For a 3×3 matrix, ...

Read More
Showing 14221–14230 of 61,297 articles
Advertisements