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
Counting steps to make number palindrome in JavaScript
We are required to write a JavaScript function that takes in a number, num, as the first and the only argument. Our function should return the number of special steps needed to obtain a palindrome. The special step is: "reverse the digits, and add to the original number". If the resulting number is not a palindrome, repeat the procedure with the sum until the resulting number is a palindrome. Problem Example For example, if the input to the function is: const num = 87; The expected output is 4 steps because: ...
Read MoreHow to create an Ellipse with a border color using FabricJS?
In this tutorial, we are going to create an Ellipse with a border color using FabricJS. Ellipse is one of the various shapes provided by FabricJS. In order to create an ellipse, we will create an instance of fabric.Ellipse class and add it to the canvas. Since FabricJS is extremely flexible, we are allowed to customize our ellipse object in any way we like. One of the properties that FabricJS provides is borderColor which allows us to manipulate the color of the border when our object is active. Syntax new fabric.Ellipse({ borderColor: String }: Object) ...
Read MoreHow to change the font weight of a Textbox using FabricJS?
In this tutorial, we are going to see how to change the font weight of a Textbox using FabricJS. We can customize, stretch or move around the text written in a textbox. In order to create a textbox, we will have to create an instance of fabric.Textbox class and add it to the canvas. Font weight refers to the value which determines how bold or light our text will appear. Syntax new fabric.Textbox(text: String, { fontWeight: Number|String }: Object) Parameters text − This ...
Read MoreHow to zoom in and zoom out images using JavaScript?
The zoom-in and zoom-out functionality is essential for image interaction. By zooming in, users can examine image details closely, while zooming out provides a broader view. This feature is particularly useful for reading small text, viewing detailed graphics, or navigating large images. In this tutorial, we will learn to implement zoom functionality for images using JavaScript by manipulating CSS properties. Using Height and Width Properties The most straightforward approach is to modify the image's height and width properties. By increasing these values, we zoom in; by decreasing them, we zoom out. Syntax // Zoom ...
Read MoreFinding shortest word in a string in JavaScript
We are required to write a JavaScript function that takes in a string and returns the shortest word from the string. For example: If the input string is: const str = 'This is a sample string'; Then the output should be: 'a' Using Array.reduce() Method This approach splits the string into words and uses reduce() to find the shortest word by comparing lengths: const str = 'This is a sample string'; const findSmallest = str => { const strArr = str.split(' '); ...
Read MoreSearch by id and remove object from JSON array in JavaScript
Suppose, we have an array of objects that contains data about some movies like this − const arr = [ {id: "1", name: "Snatch", type: "crime"}, {id: "2", name: "Witches of Eastwick", type: "comedy"}, {id: "3", name: "X-Men", type: "action"}, {id: "4", name: "Ordinary People", type: "drama"}, {id: "5", name: "Billy Elliot", type: "drama"}, {id: "6", name: "Toy Story", type: "children"} ]; We are required to write ...
Read MoreLongest decreasing subsequence subarray in JavaScript
We are required to write a JavaScript function that takes in an array of integers and returns the length of the longest consecutive decreasing subsequence (subarray) from the array. Problem Statement Given an array of integers, find the length of the longest contiguous subsequence where each element is smaller than the previous one. For example, if the input array is: const arr = [5, 2, 5, 4, 3, 2, 4, 6, 7]; The longest decreasing subsequence is [5, 4, 3, 2] with length 4. Solution Approach We'll track the current decreasing ...
Read MoreAdding and searching for words in custom Data Structure in JavaScript
We are required to design a data structure in JavaScript that supports two key operations: adding words and searching with pattern matching using regular expressions. Problem The data structure must support the following operations: addWord - adds a word to the data structure using arrays or any other storage mechanism search - searches for a literal word or a regular expression pattern containing lowercase letters "a-z" or "." where "." can represent any single letter Example Requirements addWord("sir") addWord("car") addWord("mad") search("hell") === false search(".ad") === true search("s..") === true ...
Read MoreRemoving parentheses from mathematical expressions in JavaScript
When working with mathematical expressions in JavaScript, you may need to remove parentheses while preserving the correct operations and operands. This involves carefully tracking signs and handling nested expressions. Problem We need to write a JavaScript function that takes a string of mathematical expressions and removes parentheses while keeping operations and operands in their correct positions with proper signs. For example, if the input is: const str = 'u-(v-w-(x+y))-z'; The expected output should be: u-v+w+x+y-z How It Works The algorithm uses a stack to track sign changes when ...
Read MoreHow to create an Ellipse with crosshair cursor on hover over objects using FabricJS?
In this tutorial, we are going to create an Ellipse 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.Ellipse({ hoverCursor: String }: Object) Parameters ...
Read More