Creating all possible unique permutations of a string in JavaScript

AmitDiwan
Updated on 15-Mar-2026 23:19:00

1K+ Views

We are required to write a JavaScript function that takes in a string str. Our function should create all permutations of the input string and remove duplicates, if present. This means, we have to shuffle all letters from the input in all possible orders. Problem When generating permutations of strings with repeated characters, we need to avoid duplicate permutations. For example, the string "aabb" should not generate identical permutations like "aabb" appearing multiple times. Algorithm Approach The solution uses recursion with duplicate checking: For each character position, try placing each unique character Skip duplicate ... Read More

Can split array into consecutive subsequences in JavaScript

AmitDiwan
Updated on 15-Mar-2026 23:19:00

330 Views

We are required to write a JavaScript function that takes in an array of sorted integers and determines if we can split it into consecutive subsequences of at least 3 elements each. Problem Statement Our function should return true if we can split the array into 1 or more subsequences where each subsequence consists of consecutive integers and has length at least 3, false otherwise. Input: const arr = [1, 2, 3, 3, 4, 5]; Expected Output: true Explanation: We can split the array into two consecutive subsequences: 1, 2, ... Read More

How to create a canvas with help cursor on hover over objects using FabricJS?

Rahul Gurung
Updated on 15-Mar-2026 23:19:00

471 Views

In this article, we are going to create a canvas with a help cursor on hover using FabricJS. The help cursor is one of the native cursor styles available which can be used in FabricJS canvas applications. FabricJS provides various types of cursors such as default, all-scroll, crosshair, col-resize, row-resize, etc. that reuse the native cursor under the hood. The hoverCursor property sets the style of the cursor when hovered over a canvas object. Syntax new fabric.Canvas(element: HTMLElement|String, { hoverCursor: String }: Object) Parameters ... Read More

How to Add Google Maps to a Website?

Mayank Agarwal
Updated on 15-Mar-2026 23:19:00

1K+ Views

In this article, we will be exploring Google Maps and how to add or embed google maps into our HTML template/website. Once the Google Maps are embedded into the website we can pin a location in it to display the user the current position of the store or a company. Steps to Embed Google Maps Below are the steps that need to be followed to embed Google Maps into your HTML pages: We need to generate an API key to be able to use Google maps privately. Creating the HTML ... Read More

How to set the padding of a Circle using FabricJS?

Rahul Gurung
Updated on 15-Mar-2026 23:19:00

342 Views

In this tutorial, we are going to learn how to set the padding of a Circle using FabricJS. Circle is one of the various shapes provided by FabricJS. In order to create a circle, we will have to create an instance of fabric.Circle class and add it to the canvas. Just as we can specify the position, colour, opacity and dimension of a circle object in the canvas, we can also set the padding of a circle object. This can be done by using the padding property. Syntax new fabric.Circle({ padding : Number }: Object) ... Read More

How to set the style of controlling corners of a Triangle using FabricJS?

Rahul Gurung
Updated on 15-Mar-2026 23:19:00

283 Views

In this tutorial, we are going to learn how to set the style of controlling corners of Triangle using FabricJS. Triangle is one of the various shapes provided by FabricJS. In order to create a triangle, we will have to create an instance of fabric.Triangle class and add it to the canvas. The controlling corners of an object allow us to scale, stretch or change its position. We can customize our controlling corners in many ways such as adding a specific colour to it, changing its size, etc. We can change the style by using the cornerStyle property. ... Read More

What are the attributes that work differently between React and HTML?

Imran Alam
Updated on 15-Mar-2026 23:19:00

378 Views

React and HTML handle attributes differently, which can cause confusion for developers. While HTML attributes are always strings, React treats some attributes as JavaScript expressions and has specific naming conventions that differ from standard HTML. Key Differences in Attribute Handling The main differences between React and HTML attributes include: Naming Convention: React uses camelCase (onClick) vs HTML's lowercase (onclick) JavaScript Expressions: React attributes can accept JavaScript functions and expressions Special Attributes: Some HTML attributes have different names in React Boolean Handling: React handles boolean attributes differently than HTML Event Handler Attributes React event ... Read More

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

Rahul Gurung
Updated on 15-Mar-2026 23:19:00

373 Views

In this tutorial, we are going to create a Text with a dash pattern border using FabricJS. We can display text on canvas by adding an instance of fabric.Text. Not only does it allow us to move, scale and change the dimensions of the text but it also provides additional functionality like text alignment, text decoration, line height which can be obtained by the properties textAlign, underline and lineHeight respectively. We can change the appearance of the dashes of border, by using the borderDashArray property. However, our text object must have borders in order for this property to work. If ... Read More

How to disable a specific control point of Line object using FabricJS?

Rahul Gurung
Updated on 15-Mar-2026 23:19:00

391 Views

In this tutorial, we are going to learn about how to disable a specific control point of Line object using FabricJS. A Line element is one of the basic elements provided in FabricJS. It is used for creating straight lines. Because line elements are geometrically one-dimensional and do not contain an interior, they are never filled. We can create a line object by creating an instance of fabric.Line, specifying the x and y coordinates of the line and adding it to the canvas. In order to disable a specific control point of Line object, we use the setControlVisible method. ... Read More

How to add float numbers using JavaScript?

AmitDiwan
Updated on 15-Mar-2026 23:19:00

5K+ Views

In JavaScript, floating-point numbers can be added directly using the addition operator (+). The parseFloat() function converts strings to floating-point numbers, but is not required when working with numeric literals. Example 1: Direct Addition The simplest way to add float numbers is using the addition operator directly: let inputFloat1 = 2.3; let inputFloat2 = 3.5; console.log("The two float values are:", inputFloat1, "and", inputFloat2); let result = inputFloat1 + inputFloat2; console.log("The sum of the float values is:", result); The two float values are: 2.3 and 3.5 The sum of the float values ... Read More

Advertisements