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 words in a matrix in JavaScript
We need to write a JavaScript function that takes a 2D character matrix and a string, then determines if the string can be formed by connecting adjacent characters in the matrix without reusing any position. The function searches for a path through the matrix where each character in the target string appears in sequence through adjacent cells (up, down, left, right). Each cell can only be used once per word search. Problem Example Given this matrix and target string: const arr = [ ['s', 'd', 'k', 'e'], ...
Read MoreSumming array of string numbers using JavaScript
Problem We are required to write a JavaScript function that takes in an array that contains integers and string numbers. Our function should sum all the integers and string numbers together to derive a new number and return that number. Example Following is the code − const arr = [67, 45, '34', '23', 4, 6, '6']; const mixedSum = (arr = []) => { let sum = 0; for(let i = 0; i < arr.length; i++){ const el = arr[i]; ...
Read MoreHow to return true if the parent element contains the child element in JavaScript?
In this tutorial, we are going to look at how we can return true if the parent element contains the child element in JavaScript. Assuming you have two HTML elements, a parent element, and a child element, and you want to know if the parent element contains the child element. Using the Node.contains() method The Node interface's contains() method returns a Boolean value, indicating whether a node is a descendant of a given node or not. If you want to know if the parent element contains the child element, you can use the Node.contains() method. Syntax ...
Read MoreJavaScript vs. PHP: Which is Easier?
When choosing between JavaScript and PHP for web development, understanding their differences helps determine which might be easier for your specific needs and background. What is PHP? PHP is a server-side scripting language designed for web development. Created in 1994, it's particularly strong for building dynamic websites and web applications. PHP runs on the server and generates HTML that gets sent to the browser. What is JavaScript? JavaScript is a versatile programming language that runs both in browsers (client-side) and on servers (with Node.js). Originally created for adding interactivity to web pages, it has evolved into ...
Read MoreFabricJS – Implementing object duplication programmatically on a Polygon?
We can create a Polygon object by creating an instance of fabric.Polygon. A polygon object can be characterized by any closed shape consisting of a set of connected straight-line segments. Since it is one of the basic elements of FabricJS, we can also easily customize it by applying properties like angle, opacity etc. In order to implement object duplication programmatically we need to implement duplicate control using the clone method. Syntax clone(callback: Object, propertiesToInclude: Array) Parameters Callback (optional) − This parameter is a ...
Read MoreAddition multiplication ladder in an array in JavaScript
We are required to write a JavaScript function that takes in an array of numbers and returns the alternative multiplicative sum of the elements. For example: If the array is − const arr = [1, 2, 3, 4, 5, 6, 7]; Then the output should be calculated like this − 1*2+3*4+5*6+7 2+12+30+7 And the output should be − 51 Let's write the code for this function − How It Works The algorithm pairs elements at even indices with their next element, multiplies them, and adds ...
Read MoreProgram to make vowels in string uppercase and change letters to next letter in alphabet (i.e. z->a) in JavaScript
We need to write a JavaScript function that takes a string and performs two transformations: convert vowels to uppercase and shift each letter to the next letter in the alphabet (with 'z' wrapping to 'a'). The function should construct a new string based on the input string where all vowels are uppercased and each alphabet character moves to the next letter in sequence. Problem Understanding For example, if the input string is: const str = 'newString'; The expected output should be: const output = 'oExSusIoh'; Here's how the transformation ...
Read MoreFinding all possible subsets of an array in JavaScript
Finding all possible subsets of an array is a common algorithmic problem. A subset is any combination of elements from the original array, including the empty set and the full array itself. For an array of n elements, there are 2^n possible subsets. This is because each element can either be included or excluded from a subset. For example, if the input array is: const arr = [1, 2, 3]; The output should contain all possible subsets: [ [], [1], [2], [3], ...
Read MoreFinding average age from array of Objects using JavaScript
Problem We need to write a JavaScript function that takes an array of objects containing people's data and calculates the average age from the age property. Example Following is the code: const people = [ { fName: 'Ashish', age: 23 }, { fName: 'Ajay', age: 21 }, { fName: 'Arvind', age: 26 }, { fName: 'Mahesh', age: 28 }, { fName: 'Jay', age: 19 }, ]; const findAverageAge = (arr = []) => { ...
Read MoreHow to convert a string into an integer without using parseInt() function in JavaScript?
The parseInt() is a built-in function in JavaScript that parses a string and returns an integer. However, there are times when we want to convert a string into an integer without using this function. In this article, we'll explore several alternative methods to achieve this conversion. Using the Unary Plus Operator One way to convert a string into an integer is by using the unary plus operator (+). This operator converts its operand into a number. For instance, the following program converts the string "123" into the number 123: Unary Plus ...
Read More