How to filter an array from all elements of another array – JavaScript?

Yaswanth Varma
Updated on 15-Mar-2026 23:19:00

662 Views

In JavaScript, filtering an array to exclude elements present in another array is a common task. This involves removing all elements from the first array that match any element in the second array. When storing multiple values in a single variable, arrays are used. Each element of an array has a numeric index that enables access to it. Arrays in JavaScript begin at index zero and can be modified using various methods. Using filter() with includes() (Recommended) The most straightforward approach combines filter() with includes() to exclude matching elements: ... Read More

Finding day of week from date (day, month, year) in JavaScript

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

815 Views

We are required to write a JavaScript function that takes in three arguments, namely: day, month and year. Based on these three inputs, our function should find the day of the week on that date. For example: If the inputs are − day = 15, month = 8, year = 1993 Output Then the output should be − const output = 'Sunday' Using Built-in Date Object (Simple Method) The easiest approach is to use JavaScript's built-in Date object: function getDayOfWeek(day, month, year) { ... Read More

JavaScript - Determine all possible ways a group of values can be removed from a sequence

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

163 Views

We are required to write a JavaScript function that determines how many different ways we can remove a group of values from a sequence, leaving the original sequence in order (stable), and making sure to remove only one instance of each value from the original sequence. For example − If the sequence array is − const arr = [1, 2, 1, 3, 1, 4, 4]; And the array to be removed is − const arr2 = [1, 4, 4]; Then there are three possible ways of doing this without disrupting the ... Read More

Recursive Staircase problem in JavaScript

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

748 Views

The staircase problem is a classic dynamic programming problem in computer science. Given n stairs, a person standing at the bottom wants to reach the top. The person can climb either 1 or 2 stairs at a time, and we need to count the number of ways to reach the top. We'll write a JavaScript function that takes a number n representing the number of stairs and returns the total number of ways to climb them. Understanding the Problem This problem follows the Fibonacci sequence pattern. For n stairs: 1 stair: 1 way (take 1 step) ... Read More

Maximum absolute difference of the length of strings from two arrays in JavaScript

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

332 Views

Problem We are required to write a JavaScript function that takes in two arrays, a1 and a2 of strings. Each string is composed with letters from a to z. Let x be any string in the first array and y be any string in the second array. Our function should find the value of − max(abs(length(x) − length(y))) Approach To find the maximum absolute difference, we need to: Find the longest string from both arrays Find the shortest string from both arrays ... Read More

crypto.privateDecrypt() Method in Node.js

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

2K+ Views

The crypto.privateDecrypt() method is used for decrypting data that was previously encrypted using the corresponding public key with crypto.publicEncrypt(). This method is essential for implementing asymmetric encryption in Node.js applications. Syntax crypto.privateDecrypt(privateKey, buffer) Parameters The method accepts the following parameters: privateKey – Can be an Object, String, Buffer, or KeyObject containing: oaepHash – Hash function for OAEP padding and MGF1. Default: 'sha1' oaepLabel – Label for OAEP padding. ... Read More

How to encode and decode a URL in JavaScript?

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

6K+ Views

Encoding and decoding URLs is essential in web development for handling special characters in URLs. When making GET requests to APIs with query parameters, proper encoding ensures URLs are transmitted correctly. Browsers often handle this automatically, but understanding these methods is crucial. For example, a space " " is encoded as %20 or + depending on the context. Understanding URL Encoding Methods JavaScript provides two main functions for URL encoding: encodeURI() − Encodes a complete URI while preserving URL structure characters like :, /, ?, #, &, = encodeURIComponent() ... Read More

How to add curves to a Rectangle using FabricJS?

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

2K+ Views

In this tutorial, we are going to learn how to add curves to a Rectangle 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 customize a rectangle object by specifying its position, colour, opacity and dimension. However, we can also use properties like rx and ry which allow us to assign the horizontal and vertical border radius of a Rectangle. Syntax new fabric.Rect({ rx : Number, ry: Number }: ... Read More

How to get the object scale factor of Text using FabricJS?

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

318 Views

In this tutorial, we are going to learn how to get the object scale factor of Text 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 also find the object scale factor by using the getObjectScaling method. Syntax getObjectScaling() This method returns an object containing the scaleX ... Read More

How to upload an image using HTML and JavaScript in Firebase?

Kalyan Mishra
Updated on 15-Mar-2026 23:19:00

7K+ Views

Firebase is a Google cloud platform that provides storage, database, and authentication services. In this tutorial, you'll learn how to upload images to Firebase Storage using HTML and JavaScript. Firebase is a comprehensive cloud platform offering NoSQL databases, real-time hosting, authentication, push notifications, and file storage services for web and mobile applications. Prerequisites Before starting, you need to create a Firebase project and configure storage. Follow these steps to set up your Firebase project: Firebase Project Setup STEP 1 − Visit the Firebase Console and click "Get started", then "Create a project". STEP 2 ... Read More

Advertisements