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
Converting alphabets to Greek letters in JavaScript
Converting alphabets to Greek letters in JavaScript requires creating a mapping between English and Greek characters, then replacing each character accordingly. Character Mapping First, let's establish the mapping between English and Greek letters: A=α (Alpha) B=β (Beta) D=δ (Delta) E=ε (Epsilon) I=ι (Iota) K=κ (Kappa) N=η (Eta) O=θ (Theta) P=ρ (Rho) R=π (Pi) T=τ (Tau) U=μ (Mu) V=υ (Upsilon) W=ω ...
Read MoreHow to disable the centered rotation of Textbox using FabricJS?
In this tutorial, we are going to learn how to disable the centered rotation of 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. By default, all objects in FabricJS use their center as the point of rotation. However, we can change this behaviour by using the centeredRotation property. Syntax new fabric.Textbox(text: String, { centeredRotation: Boolean }: Object) Parameters ...
Read MoreComputing zeroes (solutions) of a mathematical equation in JavaScript
We are required to write a JavaScript function that takes in three numbers representing the coefficients of a quadratic equation (ax² + bx + c = 0). The function should find the real roots of the equation or return false if the roots are complex (non-real). A quadratic equation has real roots when its discriminant (b² - 4ac) is greater than or equal to zero. The roots are calculated using the quadratic formula: x = (-b ± √discriminant) / (2a). Syntax // Quadratic formula: x = (-b ± √(b² - 4ac)) / (2a) // Discriminant = ...
Read MorePicking out uniques from an array in JavaScript
Suppose we have an array that contains duplicate elements like this − const arr = [1, 1, 2, 2, 3, 4, 4, 5]; We are required to write a JavaScript function that takes in one such array and returns a new array. The array should only contain the elements that only appear once in the original array. Therefore, let's write the code for this function − Method 1: Using indexOf() and lastIndexOf() This approach compares the first and last occurrence of each element. If they're different, the element appears multiple times: ...
Read MoreHow to do case insensitive string comparison of strings in JavaScript
In this tutorial, we will learn how to do a case-insensitive string comparison of strings in JavaScript. Case insensitive comparison means strings should be considered equal regardless of whether they are written in lowercase or uppercase letters. This technique is commonly used in search functionality, where "TutorialsPoint" and "tutorialspoint" should be treated as identical. There are four main methods to perform case-insensitive string comparisons: toUpperCase() toLowerCase() localeCompare() RegExp() Using the toUpperCase() Method The toUpperCase() method converts all alphabetic ...
Read MoreCan form target array from source array JavaScript
We are given an array of distinct integers, let's say arr, and another array of integer arrays, let say sourceArr. In the sourceArr array, the integers are distinct. We should write a function that forms arr by concatenating the arrays in sourceArr in any order. However, we cannot reorder the integers inside of any subarray in the sourceArr. We should return true if it is possible to form the array arr from sourceArr, false otherwise. For example: const arr = [23, 67, 789]; const sourceArr = [[23], [789, 67]]; The function should return ...
Read MoreSplitting array of numbers into two arrays with same average in JavaScript
We are required to write a JavaScript function that takes in an array of integers as the first and the only argument. The function needs to determine whether there exists a combination of elements of the input array that when they are divided into two groups (may/may not have equal elements), the average of both the groups is just the same. If there exists any such condition the function should return true, false otherwise. For example − If the input array is − const arr = [6, 3, 2, 8, 1, 5, 7, 4]; ...
Read MoreSum which is divisible by n in JavaScript
We need to write a JavaScript function that counts the number of contiguous subarrays whose sum is divisible by a given number. This problem uses modular arithmetic and prefix sums for an efficient solution. Problem Statement Given an array of numbers and a divisor, find how many contiguous subarrays have a sum divisible by the divisor. Input: arr = [4, 5, 0, -2, -3, 1], num = 5 Output: 7 Output Explanation There are 7 subarrays with a sum divisible by 5: [4, 5, 0, -2, -3, 1], [5], [5, 0], ...
Read MoreReturning the value of (count of positive / sum of negatives) for an array in JavaScript
Problem We are required to write a JavaScript function that takes in an array of integers (positives and negatives) and our function should return an array, where the first element is the count of positives numbers and the second element is sum of negative numbers. Using Array.reduce() Method The most efficient approach uses the reduce() method to iterate through the array once and accumulate both values simultaneously. const arr = [1, 2, 1, -2, -4, 2, -6, 2, -4, 9]; const posNeg = (arr = []) => { const result = arr.reduce((acc, ...
Read MoreReturning just greater array in JavaScript
We need to write a JavaScript function that takes an array of positive integers, joins them to form a single number, adds 1 to that number, and returns the result as an array of digits. Problem Statement Given an array of positive integers, we need to: Join the digits to form a single number Add 1 to that number Return the result as an array of individual digits For example, if the input array is [6, 7, 3, 9], it represents the number 6739. Adding 1 gives us 6740, which should be returned as [6, ...
Read More