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
Sorting Array without using sort() in JavaScript
Sorting arrays without using the built-in sort() method is a common programming challenge that helps understand sorting algorithms. JavaScript provides several approaches to implement custom sorting logic. Using Array.reduce() for Insertion Sort The reduce() method can implement insertion sort by building a sorted array incrementally: const arr = [4, 56, 5, 3, 34, 37, 89, 57, 98]; const sortWithReduce = arr => { return arr.reduce((acc, val) => { let ind = 0; while(ind < acc.length ...
Read MoreHow to find a value is present in binary tree or not in JavaScript ?
We are required to write a JavaScript function on the prototype object of a BinarySearchTree data type that takes in a value and finds whether or not that value is contained in the BST. Binary Search Tree Structure A Binary Search Tree (BST) is a tree data structure where each node has at most two children. The left child contains values smaller than the parent, and the right child contains values greater than the parent. 50 30 ...
Read MoreN consecutive odd numbers JavaScript
In this problem statement, our target is to print the n consecutive odd numbers and implement this problem with the help of Javascript functionalities. We can solve this problem using loops and array manipulation in JavaScript. Logic for the Given Problem In the given problem statement we have to design a program to generate a given number of consecutive odd numbers starting from 1. It will be done by creating an empty array to store the odd numbers and then using a loop which will run n times to add every odd number to the created array. ...
Read MoreAlternatingly combining array elements in JavaScript
We are required to write a JavaScript function that takes in any number of arrays of literals as input. Our function should prepare a new array that contains elements picked alternatingly from all the input arrays. For example, if the input to the function is − Problem Input const arr1 = [1, 2, 3, 4]; const arr2 = [11, 12, 13, 14]; const arr3 = ['a', 'b', 'c']; Expected Output const output = [1, 11, 'a', 2, 12, 'b', 3, 13, 'c', 4, 14]; The function should take ...
Read MoreHow to lock the vertical skewing of Ellipse using FabricJS?
In this tutorial, we are going to learn how to lock the vertical skewing of an Ellipse using FabricJS. Just as we can specify the position, color, opacity and dimension of an ellipse object in the canvas, we can also specify whether we want to stop skewing an object vertically. This can be done by using the lockSkewingY property. Syntax new fabric.Ellipse({ lockSkewingY : Boolean }: Object) Parameters options (optional) − This parameter is an Object which provides additional customizations to our ellipse. Using this parameter color, cursor, stroke ...
Read MoreHow to create a string by joining the elements of an array in JavaScript?
In this tutorial, we will see how to create a string by joining the elements of an array in JavaScript. We will explore two different approaches: using the addition operator (+) to manually concatenate elements, and using the built-in join() method, which is the recommended approach. Using the Addition Operator (+) In this approach, we manually loop through the array and concatenate each element with a separator using the addition operator. While this works, it's more verbose than using the built-in join() method. Algorithm STEP 1 − Create an array with ...
Read MoreHow is Ajax different from JavaScript Libraries and Run Time Environments?
This article explores AJAX (Asynchronous JavaScript and XML) and clarifies how it differs from JavaScript libraries and runtime environments in web development. AJAX Introduction and History Ajax, short for Asynchronous JavaScript and XML, is a technique for creating dynamic and interactive web applications. It was first introduced in the early 2000s and has since become a staple of modern web development. The key feature of Ajax is its ability to update parts of a web page without requiring a full page reload. This is achieved by using JavaScript to send and receive data from a server asynchronously, ...
Read MoreFinding the smallest fitting number in JavaScript
We are required to write a JavaScript function that takes in an array of numbers and returns a number which can exactly divide all the numbers in the array. This is essentially finding the Greatest Common Divisor (GCD) of all numbers. Therefore, let's write the code for this function − Example The code for this will be − const arr = [4, 6, 34, 76, 78, 44, 34, 26, 88, 76, 42]; const dividesAll = el => { const result = []; let num; ...
Read MoreGenerating a random number that is divisible by n in JavaScript
We are required to write a JavaScript function that takes in a number as the only argument. The function should then return a random generated number which is always divisible by the number provided by the argument. Approach To generate a random number divisible by n, we generate a random number within a range, divide it by n, round the result, and multiply back by n. This ensures the final number is always a multiple of n. Example The code for this will be: const num = 21; // function that generates random ...
Read MoreJavaScript Count repeating letter
In this problem statement, our target is to count the repeating letter in the given string with the help of Javascript functionalities. So we can solve this problem with the help of loops and some built-in methods of Javascript. Logic for the given problem In the given problem statement we have to design a program to count the repeating letters in the given string. For implementing this task first we will create a blank object for count, array for repeated characters and another object for results. Then we will loop through every character in the string. So ...
Read More