Articles on Trending Technologies

Technical articles with clear explanations and examples

Checking for string anagrams JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 15-Mar-2026 423 Views

In this problem statement, our aim is to check for string anagrams with the help of Javascript functionalities. So for solving this problem first we need to understand the problem in simple terms. Understanding the Problem Statement We have given two strings as input and our main aim is to check if the strings are anagrams of each other. If they are anagrams then return true otherwise return false. What are Anagrams? An anagram is a word or phrase formed by rearranging the letters of another word or phrase, using all the original letters exactly once. ...

Read More

Finding intersection of arrays that contain repetitive entries in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 195 Views

Finding the intersection of arrays with repetitive entries means identifying common elements between two arrays while preserving duplicate occurrences. This is different from a simple set intersection, as we need to consider the frequency of each element. The function should build a third array based on the two input arrays that contains all the elements that are common to both arrays. If there are multiple instances of the same element present in both arrays, we need to include all such instances up to the minimum count found in either array. Problem Example If the input arrays are: ...

Read More

Merging two sorted arrays into one sorted array using JavaScript

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

We are required to write a JavaScript function that takes in two sorted arrays of numbers. Our function should merge all the elements of both arrays into a new array and return that new array sorted in the same order. Two-Pointer Approach The most efficient approach uses two pointers to traverse both arrays simultaneously, comparing elements and adding the smaller one to the result array. const arr1 = [1, 3, 4, 5, 6, 8]; const arr2 = [4, 6, 8, 9, 11]; const mergeSortedArrays = (arr1 = [], arr2 = []) => { ...

Read More

How to create a Circle with crosshair cursor on hover over objects using FabricJS?

Rahul Gurung
Rahul Gurung
Updated on 15-Mar-2026 340 Views

In this tutorial, we are going to create a Circle with a crosshair cursor on hover over objects using FabricJS. crosshair is one of the native cursor styles available which can be used in the FabricJS canvas too. FabricJS provides various types of cursors like default, all-scroll, crosshair, col-resize, row-resize etc which are reusing the native cursor underhood. The hoverCursor property sets the style of the cursor when hovered over a canvas object. Syntax new fabric.Circle({ hoverCursor: String }: Object) Parameters options (optional) ...

Read More

Finding the index of the first repeating character in a string in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 652 Views

We are required to write a JavaScript function that takes in a string and returns the index of the first character that appears twice in the string. If there is no such character then we should return -1. Let's say the following is our string − const str = 'Hello world, how are you'; We need to find the index of the first repeating character. Understanding the Problem In the string "Hello world, how are you", we need to find which character repeats first. The character 'l' appears at index 2 and again ...

Read More

Best way to find length of JSON object in JavaScript

Nikhilesh Aleti
Nikhilesh Aleti
Updated on 15-Mar-2026 17K+ Views

In JavaScript, objects don't have a built-in length property like arrays. However, there are several reliable methods to find the number of properties in a JSON object. Input-Output Scenario Consider an object with some keys and values. We need to get the count of its properties: const MyObj = { Name: "Mike", Age: 34 }; console.log(Object.keys(MyObj).length); // Output: 2 Using Object.keys() (Recommended) The Object.keys() method returns an array of a given object's own enumerable property names. It returns the keys in the same order as they ...

Read More

Removing duplicates from a sorted array of literals in JavaScript

Sakshi Jain
Sakshi Jain
Updated on 15-Mar-2026 376 Views

When working with sorted arrays in JavaScript, removing duplicates is a common operation. Since the array is already sorted, duplicate elements appear consecutively, making the removal process more efficient. What is a Sorted Array? A sorted array is an array where elements are arranged in a specific order (ascending or descending). In JavaScript, this ordering makes it easier to identify and remove duplicate elements since identical values are grouped together. const sortedArray = [1, 2, 2, 3, 4, 6, 6]; // After removing duplicates const uniqueArray = [1, 2, 3, 4, 6]; Method 1: ...

Read More

Reversing the words within keeping their order the same JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 15-Mar-2026 1K+ Views

In JavaScript, we can reverse each word in a string while maintaining their original positions. This means "Hello World" becomes "olleH dlroW" - each word is reversed individually, but their order remains unchanged. Understanding the Problem We need a function that takes a string and returns a new string where each word is reversed, but the word positions stay the same. For example: Input: "Hello World" Output: "olleH dlroW" The word order is preserved, but each word's characters are reversed. Method 1: Using Built-in Methods (Recommended) The most efficient approach uses JavaScript's ...

Read More

Formatting a string to separate identical characters in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 198 Views

In JavaScript, we often need to rearrange string characters so that no two identical characters are adjacent to each other. This is a classic string manipulation problem that requires careful character distribution. The function should reorganize the characters in the input string such that no two identical characters are placed next to each other. If such an arrangement is possible, it returns the rearranged string; otherwise, it returns an empty string. Problem Understanding Given a string like 'add', we need to rearrange it to 'dad' where no two identical characters are adjacent. The key insight is that ...

Read More

How to create a Circle with dash pattern border using FabricJS?

Rahul Gurung
Rahul Gurung
Updated on 15-Mar-2026 303 Views

In this tutorial, we are going to create a circle with a dash pattern border using FabricJS. Circle is one of the various shapes provided by FabricJS. In order to create a circle, we will create an instance of fabric.Circle class and add it to the canvas. We can change the appearance of the dashes of border, by using the borderDashArray property. However, our circle object must have borders in order for this property to work. If the hasBorders property is assigned a false value, this property will not work. Syntax new fabric.Circle({ borderDashArray: Array }: Object) ...

Read More
Showing 14811–14820 of 61,297 articles
Advertisements