Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Front End Technology Articles
Page 302 of 652
JavaScript - How to create nested unordered list based on nesting of array?
In this tutorial, we'll learn how to create nested unordered lists in HTML using JavaScript. We'll use recursion to traverse nested arrays and generate the corresponding HTML structure dynamically. Understanding the Problem We need to convert a nested array structure into an HTML unordered list where: String elements become list items Array elements become nested sublists The structure preserves the original nesting levels For example: Coffee ...
Read MoreJavaScript Count repeating letter
In this problem statement, our target is to count the repeating letter in the given string with the help of Javascript functionalities. So we can solve this problem with the help of loops and some built-in methods of Javascript. Logic for the given problem In the given problem statement we have to design a program to count the repeating letters in the given string. For implementing this task first we will create a blank object for count, array for repeated characters and another object for results. Then we will loop through every character in the string. So ...
Read MoreFinding Lucky Numbers in a Matrix in JavaScript
In the given problem statement we have to write a function to get the lucky numbers in a matrix with the help of Javascript. A lucky number is defined as an element that is the minimum value in its row and the maximum value in its column. Understanding the Problem Statement A lucky number in a matrix must satisfy two conditions: It is the minimum element in its row It is the maximum element in its column For example, in the matrix [[3, 7], [9, 11]], the number 7 ...
Read MoreMapping values to keys JavaScript
In JavaScript, mapping values to keys means creating associations between identifiers (keys) and their corresponding data (values). This is commonly achieved using objects, which store data in key-value pairs for efficient retrieval. Understanding the Problem Objects in JavaScript are data structures that store information as key-value pairs. Keys serve as identifiers to access their associated values. There are several ways to access these values, with dot notation and bracket notation being the most common approaches. For example, with an object const obj = {name: 'John', age: 30}, you can access the name using obj.name or obj['name']. ...
Read MoreMasking a string JavaScript
Masking a string means replacing certain characters with asterisks (*) or other symbols to hide sensitive information like passwords, credit card numbers, or personal data. In JavaScript, we can create a function to mask specific portions of a string while keeping the rest visible. Understanding String Masking String masking is commonly used in applications to protect sensitive data while still showing partial information for verification purposes. For example, displaying a credit card number as "1234-****-****-5678" or an email as "j***@example.com". Basic Masking Function Here's a function that masks characters between specified start and end positions: ...
Read MoreMaximum difference between a number JavaScript
In this problem statement, our task is to write a function for finding the maximum difference between two numbers in an array using JavaScript. We'll explore both a brute force approach and an optimized solution. Understanding the Problem We need to find the maximum difference between any two numbers in an array where the larger number appears after the smaller number in the array order. For example, in array [2, 3, 5, 6, 4, 1], the maximum difference is 4 (6 - 2 = 4), not 5 (6 - 1), because 1 comes after 6. Method 1: ...
Read MoreN consecutive odd numbers JavaScript
In this problem statement, our target is to print the n consecutive odd numbers and implement this problem with the help of Javascript functionalities. We can solve this problem using loops and array manipulation in JavaScript. Logic for the Given Problem In the given problem statement we have to design a program to generate a given number of consecutive odd numbers starting from 1. It will be done by creating an empty array to store the odd numbers and then using a loop which will run n times to add every odd number to the created array. ...
Read MoreNth element of the Fibonacci series JavaScript
In this article, we'll learn how to find the nth element in the Fibonacci series using JavaScript. The Fibonacci sequence is a mathematical series where each number is the sum of the two preceding numbers. What is the Fibonacci Series? The Fibonacci sequence starts with 0 and 1, and each subsequent number is the sum of the previous two numbers. The series begins as: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89... For example, the 6th number in the series is 8, and the 10th number is 55. Using ...
Read MoreNumbers smaller than the current number JavaScript
In JavaScript, we often need to count how many numbers in an array are smaller than each element. This problem requires comparing each element against all others to build a result array showing the count of smaller numbers for each position. Understanding the Problem Given an array of integers, we need to return a new array of the same length where each element represents the count of numbers smaller than the corresponding element in the original array. For example: if we have [5, 4, 3, 2, 1], the output should be [4, 3, 2, 1, 0] because: ...
Read MoreQueue Reconstruction by Height in JavaScript
The Queue Reconstruction by Height problem involves arranging people in a queue based on their height and the number of taller people in front of them. Each person is represented as [h, k] where h is height and k is the count of people in front with height ≥ h. Understanding the Problem Given an array of people where each person is represented by [height, k], we need to reconstruct the queue. The key insight is that taller people don't affect the positioning of shorter people, so we can process people from tallest to shortest. For example, ...
Read More