Converting numbers to Indian currency using JavaScript

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

3K+ Views

Converting numbers to Indian currency format is a common requirement in web applications. JavaScript provides a built-in method to format numbers according to different locales, including the Indian numbering system. Understanding Indian Currency Format Indian currency uses a unique grouping system where numbers are grouped by hundreds (lakhs and crores) rather than thousands. For example: 1000 → ₹1, 000.00 129943 → ₹1, 29, 943.00 76768798 → ₹7, 67, 68, 798.00 Using toLocaleString() Method The toLocaleString() method with Indian locale ('en-IN') automatically handles the currency formatting: const num1 = 1000; const num2 ... Read More

How to implement backtracking for a climbing stairs practice in JavaScript?

Nikitasha Shrivastava
Updated on 15-Mar-2026 23:19:00

461 Views

In the given problem statement we are asked to implement backtracking for a climbing stairs practice with the help of JavaScript functionalities. In data structures, backtracking is popularly known to explore all possible solutions. We can solve this problem with the help of a backtracking algorithm. What is the Backtracking Technique? Backtracking is a well-known algorithmic technique, which is basically used to solve problem statements that include searching for all possible solutions. It is based on a depth-first strategy and is used in combination with a recursive method. The basic ideology for this technique is to explore ... Read More

Checking for uniqueness in an array in JavaScript

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

262 Views

We are required to write a JavaScript function that takes in an array of numbers as the first and the only argument. The function should return true if all the numbers in the array appear only once (i.e., all the numbers are unique), and false otherwise. For example − If the input array is − const arr = [12, 45, 6, 34, 12, 57, 79, 4]; Then the output should be − const output = false; because the number 12 appears twice in the array. Method 1: Using indexOf() ... Read More

Deep count of elements of an array using JavaScript

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

2K+ Views

We are required to write a JavaScript function that takes in a nested array of elements and returns the deep count of all elements present in the array, including those in nested subarrays. Problem Given a nested array, we need to count all elements at every level of nesting. Input const arr = [1, 2, [3, 4, [5]]]; Output const output = 7; Because the elements at level 1 are 2, elements at level 2 are 2 and elements at level 3 are 1. Hence the deep count is 7. Using Recursive Reduce Method ... Read More

Alternating sum of elements of a two-dimensional array using JavaScript

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

427 Views

Problem We are required to write a JavaScript function that takes in a 2-Dimensional array of m X n order of numbers. For this array, our function should calculate the alternating sum where each element is multiplied by (-1)^(i+j), where i and j are the row and column indices respectively. The mathematical formula is: $\sum_{i=1}^m \sum_{j=1}^n (-1)^{i+j}a_{ij}$ How It Works The alternating sum works by applying a positive or negative sign to each element based on its position. When the sum of row index (i) and column index (j) is even, the element gets a positive sign. When ... Read More

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

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

1K+ Views

In this article, we are going to create a canvas with a text cursor on hover using FabricJS. The text cursor is one of the native cursor styles available which can be used in the FabricJS canvas. 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 chain asynchronous functions in JavaScript?

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

2K+ Views

JavaScript is a single-threaded language that executes operations synchronously by default. Synchronous operations can be time-consuming and block other operations in the thread. JavaScript provides asynchronous programming capabilities that allow functions to execute without blocking other operations. This is achieved through asynchronous constructs like Promises, async/await, and callbacks. Asynchronous functions are powerful, but their unpredictable execution timing can create challenges. Chaining these functions ensures they execute in a specific order, making your code more predictable and easier to debug. In this article, we will explore different methods for chaining asynchronous functions using modern JavaScript features. The ... Read More

How to set the size of the controlling corners of a Circle using FabricJS?

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

607 Views

In this tutorial, we are going to learn how to set the size of the controlling corners of a Circle using FabricJS. 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 size by using the cornerSize property. Syntax new fabric.Circle({ cornerSize: Number }: Object) Parameters options (optional) − This parameter is an ... Read More

How to set the fill colour of a Rectangle using FabricJS?

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

654 Views

In this tutorial, we are going to learn how we can change the appearance of a Rectangle object by changing its fill colour using FabricJS. Rectangle is one of the various shapes provided by FabricJS. In order to create a rectangle, we will have to create an instance of fabric.Rect class and add it to the canvas. We can change the fill colour by using the fill property which allows us to specify the colour of the object's fill. Syntax new fabric.Rect({ fill: String }: Object) Parameters Options (optional) ... Read More

How to find the complexity of a Line instance using FabricJS?

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

297 Views

In this tutorial, we are going to learn about how to find the complexity of a Line 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 get the complexity of a Line object, we use the complexity method. This method will return ... Read More

Advertisements