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
Articles by Alshifa Hasnain
221 articles
How do we add a table row in HTML?
In this article, we will learn to add a table row in HTML. Tables are a fundamental part of web development, used to display structured data in rows and columns. In HTML, you can add table rows using the (table row) element inside a structure. Syntax Following is the syntax for adding a table row in HTML − Cell content Cell content Basic Table Structure Before adding rows, let's ...
Read MoreJavaScript Program to Check horizontal and vertical symmetry in binary matrix
In this article, we will learn to create a program to check both horizontal and vertical symmetry in a binary matrix in JavaScript. A binary matrix is a 2-D array that consists of one and zero only as the elements in each cell. Horizontal symmetry of a binary matrix means if the first row is the same as the last row, the second row is the same as the second last row, and so on. What are Symmetry Matrices? Symmetry in matrices refers to how the values in the matrix mirror themselves along an axis. In the ...
Read MoreJavaScript program to generate all rotations of a number
In this article, we will learn to generate all rotations of a number in JavaScript. A rotation involves moving the first digit to the end of the number, creating all possible circular arrangements of the digits. Problem Statement Given a number, we need to generate all possible rotations of its digits. A rotation is defined as moving the first digit to the end of the number. Input: 123 All Rotations: 123 (original number) 231 (first rotation: move 1 to the end) 312 (second ...
Read MoreJavaScript program to count triplets with sum smaller than a given value
In this article, we will learn to count triplets with a sum smaller than a given value in JavaScript. Triplets in an array whose sum is less than a provided number is a popular problem in competitive coding and algorithm design. Problem Statement Given an array of integers and a target sum, we need to find the number of triplets (a, b, c) where the sum of three elements is less than the given value. Input: const arr = [5, 1, 3, 4, 7]; const sum = 12; Output: 4 ...
Read MoreJavaScript Program to Find a triplet that sum to a given value
In this article, we will learn to find three numbers in an array that add up to a given sum value using JavaScript. We are going to write a JavaScript program to find a triplet that sums up a given value. This program will make use of nested loops to iterate over the input array and check for the existence of a triplet with a sum equal to the given value. We'll present two different approaches and analyze their implementations. Sorting and Two-Pointer Technique The first approach uses sorting and the two-pointer technique to solve the problem efficiently. ...
Read MoreCreate array from JSON object JavaScript
In this article, we will learn to create an array from JSON data in JavaScript. JSON is a widely used format for storing and exchanging data. A common use case involves extracting specific data from a JSON object or array and converting it into a separate array for further processing. What is JSON Data? JSON (JavaScript Object Notation) is a lightweight data format commonly used to store and exchange data between a server and a client. It represents data as key-value pairs and is easy for both humans and machines to read and write. In JavaScript, JSON objects ...
Read MoreJavaScript array sorting by level
In this article, we will learn array sorting by level in JavaScript, creating a hierarchical tree structure from a flat array is a common challenge when dealing with relational data. This is a common task when dealing with hierarchical data, such as organizational charts, category trees, or file systems, where relationships like parent-child need to be represented. Problem Statement We have an array of objects representing nodes with _id, level, and parentId properties. Our goal is to transform this array into a tree structure where nodes are nested as children under their respective parents. The elements with the ...
Read MoreJavaScript - Create an alert on clicking an HTML button
In this article, we will learn to create an alert by clicking an HTML button in JavaScript. JavaScript is extensively utilized to increase user interactions on web pages. One of the widespread usage scenarios is to display an alert on a button click. What is an Alert in JavaScript? An alert is a built-in JavaScript function that displays a small pop-up or a dialogue box window containing a message. The syntax for using an alert is: alert("Your message here"); This function pauses the execution of the script until the user dismisses the alert ...
Read MoreJavaScript union of two objects
In this article, we will learn to calculate the union of two objects in JavaScript. The union of two objects results in a new object that contains all the properties of both objects. What is the Union of Two Objects? The union of two objects is the process of combining the properties of both objects into a single object. When properties have the same key, their values are merged together. For example Input − const obj1 = { name: "John", email: "john@email.com" }; const obj2 = { name: "Jane", email: "jane@email.com" }; ...
Read MoreJavaScript Quicksort Recursive
In this article, we will learn to implement Quicksort recursively in JavaScript. Quicksort is one of the most efficient and widely used sorting algorithms, known for its divide-and-conquer approach. What is Quicksort? Quicksort is a divide-and-conquer sorting algorithm that sorts an array by selecting a pivot element and partitioning the array into two subarrays: elements smaller than the pivot and elements greater than or equal to the pivot. It then recursively sorts the subarrays. Quicksort Process ...
Read More