Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles on Trending Technologies
Technical articles with clear explanations and examples
Finding day of week from date (day, month, year) in JavaScript
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 MoreJavaScript - Determine all possible ways a group of values can be removed from a sequence
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 MoreRecursive Staircase problem in JavaScript
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 MoreMaximum absolute difference of the length of strings from two arrays in JavaScript
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 Morecrypto.privateDecrypt() Method in Node.js
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 MoreHow to encode and decode a URL in JavaScript?
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 MoreHow to add curves to a Rectangle using FabricJS?
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 MoreHow to get the object scale factor of Text using FabricJS?
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 MoreHow to upload an image using HTML and JavaScript in Firebase?
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 MoreSum all duplicate values in array in JavaScript
We need to write a JavaScript function that takes an array of numbers with duplicate entries and sums all duplicate values. Each unique number appears once in the result, multiplied by its frequency count. Problem Understanding For array [1, 3, 1, 3, 5, 7, 5, 3, 4]: 1 appears 2 times → 1 × 2 = 2 3 appears 3 times → 3 × 3 = 9 5 appears 2 times → 5 × 2 = 10 7 appears 1 time → 7 × 1 = 7 4 appears 1 time → 4 × 1 = 4 ...
Read More