Articles on Trending Technologies

Technical articles with clear explanations and examples

How to run a given array of promises in series in JavaScript?

Imran Alam
Imran Alam
Updated on 15-Mar-2026 1K+ Views

In JavaScript, there is a method called "Promise.all" that allows you to run an array of promises in parallel. However, sometimes you may want to run your promises in series instead. This can be useful if you want to make sure that each promise is executed one after the other, or if you need to use the result of one promise in the execution of the next promise. There are a few different ways that you can run an array of promises in series in JavaScript. In this article, we'll take a look at a few of them. ...

Read More

Can Search Engines Index JavaScript?

Rushi Javiya
Rushi Javiya
Updated on 15-Mar-2026 610 Views

JavaScript creates dynamic, interactive web experiences, but it presents unique challenges for search engine crawling and indexing. Understanding how search engines handle JavaScript is crucial for SEO success. How Search Engines Crawl JavaScript When crawling traditional HTML pages, the process is straightforward and fast. Googlebot downloads HTML files, extracts links from source code, and indexes content immediately. However, JavaScript-heavy websites require a more complex process: Googlebot downloads the initial HTML file but may not see JavaScript-generated links in the source code CSS and JavaScript files are then downloaded separately Google's Web Rendering Service (WRS) must parse, ...

Read More

Fetch alternative even values from a JavaScript array?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 378 Views

To fetch alternative even values from a JavaScript array, you need to iterate through the array and check if the index is even using the modulo operator. An index is even when index % 2 == 0. Syntax if (index % 2 == 0) { // This will select elements at even positions (0, 2, 4, ...) } Example The following example demonstrates how to fetch alternative even values from an array: var subjectsName = ["MySQL", "JavaScript", "MongoDB", "C", "C++", "Java"]; for (let index = 0; index ...

Read More

Merge JavaScript objects with the same key value and count them

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 4K+ Views

Suppose we have an array of objects like this: const arr = [{ "value": 10, "id": "111", "name": "BlackCat", }, { "value": 10, "id": "111", "name": "BlackCat", }, { "value": 15, "id": "777", "name": "WhiteCat", }]; We are required to write a JavaScript function that takes in one such array. The function should then merge all those objects together that ...

Read More

Checking the validity of parentheses in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 2K+ Views

We are required to write a JavaScript function that takes in a string containing just the characters: '(', ')', '{', '}', '[' and ']' Our function should determine if the input string is valid. An input string is valid if: Open brackets must be closed by the same type of brackets. Open brackets must be closed in the correct order. ...

Read More

Sum of All Possible Odd Length Subarrays in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 497 Views

We are required to write a JavaScript function that takes in an array of integers as the only argument. The function should first permute all possible subarrays from the original array that have an odd length. And then the function should find the combined sum of all the elements of those subarrays and return the sum. For example, if the input array is: const arr = [1, 2, 3]; Then the output should be: const output = 12; Because the desired subarrays are [1], [2], [3], [1, 2, 3] with ...

Read More

Problem Can we fit remaining passengers in the bus using JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 367 Views

Problem We need to write a JavaScript function that determines if a bus can accommodate all waiting passengers. The function takes three parameters: cap − the total capacity of people the bus can hold (excluding the driver) on − the number of people currently on the bus (excluding the driver) wait − the number of people waiting to board the bus If there's enough space for everyone, return 0. Otherwise, return the number of passengers who cannot board. Solution The logic is straightforward: calculate ...

Read More

Longest subarray with unit difference in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 247 Views

We need to find the length of the longest subarray where the difference between maximum and minimum values is exactly 1. This means the subarray can only contain two consecutive numbers (like 3 and 4) or just one unique number repeated. Problem Statement Given an array of numbers, find the length of the longest subarray where the difference between its maximum and minimum values is exactly 1. For example, with input array: const arr = [2, 4, 3, 3, 6, 3, 4, 8]; The longest valid subarray is [4, 3, 3, 3, 4] ...

Read More

How to use the "in" operator in JavaScript?

Mayank Agarwal
Mayank Agarwal
Updated on 15-Mar-2026 307 Views

In this article, we are going to explore the 'in' operator and how to use it in JavaScript. The in operator is an inbuilt operator in JavaScript that is used for checking whether a particular property exists in an object or not. It will return true if the property exists, else false is returned. Syntax prop in object Parameters This operator accepts the following parameters as described below − prop − This parameter holds the string or symbol that represents a property ...

Read More

How to get the sum of the powers of all numbers in JavaScript?

Imran Alam
Imran Alam
Updated on 15-Mar-2026 676 Views

In this tutorial, we'll be discussing how to get the sum of the powers of all the numbers from start to end in JavaScript. We'll be using the built-in Math.pow() method to calculate the powers and the Array reduce() method to sum up the values. Using the Math.pow() Method The Math.pow() method allows us to calculate the power of a number. We can use this method to calculate the powers of all the numbers from start to end. Syntax Math.pow(base, exponent); Parameters Base − The base number. ...

Read More
Showing 16501–16510 of 61,299 articles
Advertisements