Prabhdeep Singh

Prabhdeep Singh

161 Articles Published

Articles by Prabhdeep Singh

Page 6 of 17

JavaScript Program for Longest Subsequence of a Number having Same Left and Right Rotation

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

We will implement a code to find the longest subsequence of a given number that has the same left and right rotation in JavaScript. Left rotation moves the leftmost digit to the rightmost position, while right rotation moves the rightmost digit to the leftmost position. Understanding the Problem Given a number, we need to find a subsequence (formed by deleting some digits) where left and right rotations produce the same result. For example: Single digit sequences always have equal rotations: 1, 2, 3 Two identical digits: 11, 22, 33 Alternating patterns of even length: 1010, 2323, ...

Read More

JavaScript Program for Markov Matrix

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

A matrix is a kind of 2-D array, which is in the form of some number of rows, and for each row, there is the same number of columns and by the row and column number, we can get the element at any particular index. For the Markov matrix, each row's sum must equal 1. We are going to implement a code to create a new Markov matrix and find if the currently given matrix is a Markov matrix or not. What is a Markov Matrix? A Markov matrix is a special type of matrix where each row ...

Read More

JavaScript Program for Maximize Elements Using Another Array

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

In this article, we are going to implement a JavaScript program for maximizing elements using another array. We are given two arrays and have to pick some elements from the second array and replace the elements of the first array to maximize the sum. Problem Statement In this problem, we are given two arrays and we have to make all the elements of the first array as large as possible by replacing them with elements from the second array. Each element from the second array can only be used once. The goal is to maximize the sum of ...

Read More

JavaScript Program for Maximum Product Subarray

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

A subarray is a contiguous portion of an array. In the maximum product subarray problem, we need to find the subarray whose elements have the largest product when multiplied together. This is a classic dynamic programming problem with interesting edge cases involving negative numbers and zeros. Problem Analysis The challenge becomes complex when dealing with different types of numbers: All positive numbers: The entire array gives maximum product Contains zeros: Array splits into segments at zero positions Contains negative numbers: Even count of negatives gives positive product, ...

Read More

Integer Range in JavaScript

Prabhdeep Singh
Prabhdeep Singh
Updated on 15-Mar-2026 1K+ Views

JavaScript uses a single number type to represent all numeric values, including both integers and floating-point numbers. Unlike languages such as C++ or Java, JavaScript doesn't have separate data types for different number sizes. However, there are important limits to understand when working with large integers. JavaScript stores numbers using the IEEE 754 double-precision floating-point format, which determines the maximum and minimum values that can be safely represented and manipulated. JavaScript Number System JavaScript treats all numbers as 64-bit floating-point values. This unified approach simplifies the language but introduces precision limitations when working with very large integers. ...

Read More

Introduction and Installation of Nightmare.js

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

Nightmare.js is a high-level browser automation library developed by Segment. It's designed for automated testing and web scraping, operating as a headless browser using Electron. This library allows you to perform user interactions like clicking, typing, and navigation programmatically. What is Nightmare.js? Nightmare.js provides a simple, synchronous-style API for browser automation. Instead of dealing with complex callback structures, it exposes intuitive methods that mimic user actions such as goto, type, and click. Originally created for automating websites without APIs, it's now commonly used for: UI testing and smoke tests Web scraping and data extraction Screenshot generation ...

Read More

Introduction to Anime.js

Prabhdeep Singh
Prabhdeep Singh
Updated on 15-Mar-2026 2K+ Views

Anime.js is a lightweight JavaScript animation library with a simple yet powerful API. It works seamlessly with CSS properties, DOM elements, SVG attributes, and JavaScript objects, making it an excellent choice for creating smooth web animations without the complexity of traditional JavaScript animation methods. Traditional JavaScript animations require manually calculating property changes over time, which becomes complex even for simple effects. Anime.js simplifies this process by providing a unified interface for animating multiple properties simultaneously, handling timing calculations, and managing animation states automatically. Key Features Anime.js offers several advantages over vanilla JavaScript animations: Lightweight: Small ...

Read More

How to round up a number in JavaScript?

Prabhdeep Singh
Prabhdeep Singh
Updated on 15-Mar-2026 1K+ Views

In JavaScript, the Math.ceil() method rounds a number up to the nearest integer. Unlike regular rounding, it always rounds upward, making it useful for scenarios like calculating pages needed or ensuring minimum values. Syntax Math.ceil(x) Where x is the number to round up. The method returns the smallest integer greater than or equal to x. How Math.ceil() Works If the number is already an integer, it returns the same number If the number has any decimal part (even 0.1), it rounds up to the next integer ...

Read More

How to return which part of a positioned element is visible in JavaScript?

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

This tutorial teaches us how to return which part of a positioned element is visible in JavaScript. A positioned element is an HTML element with CSS positioning (absolute, relative, fixed, etc.). To make only a defined part visible, we use the CSS clip property to hide unwanted areas. The clip property defines a rectangular clipping region that determines which portion of an absolutely positioned element should be visible. Syntax Here's the basic syntax for clipping an element and retrieving the clip value: document.getElementById("elementId").style.clip = "rect(top right bottom left)"; let clipValue = document.getElementById("elementId").style.clip; The ...

Read More

How to replace all dots in a string using JavaScript?

Prabhdeep Singh
Prabhdeep Singh
Updated on 15-Mar-2026 5K+ Views

In this tutorial, we will explore different ways to replace all dots in a string using JavaScript. While it's possible to remove all occurrences of dots manually with a for loop, JavaScript provides built-in methods that make this task much simpler. The two most popular methods for replacing all dots in a string are: Using the replaceAll() Method The replaceAll() method replaces all occurrences of a specified pattern with a replacement string. This is the most straightforward approach for replacing all dots. Syntax string.replaceAll(searchValue, replaceValue) Parameters searchValue ...

Read More
Showing 51–60 of 161 articles
« Prev 1 4 5 6 7 8 17 Next »
Advertisements