Articles on Trending Technologies

Technical articles with clear explanations and examples

Even index sum in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 652 Views

We need to write a JavaScript function that calculates the sum of all integers at even indices (0, 2, 4, etc.) in an array, then multiplies this sum by the last element of the array. Problem Statement Given an array of integers, find the sum of elements at even indices and multiply by the last element. Input: [4, 1, 6, 8, 3, 9] Even indices: 0, 2, 4 → elements: 4, 6, 3 Sum: 4 + 6 + 3 = 13 Last element: 9 Result: 13 × 9 = 117 Solution const ...

Read More

Finding the length of longest vowel substring in a string using JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 583 Views

Problem We are required to write a JavaScript function that takes in a string. Our function should return the length of the longest contiguous substring that contains only vowels. Approach The solution uses a sliding window approach to track consecutive vowels. We maintain two variables: cur for the current vowel sequence length and max for the longest sequence found so far. Example Following is the code − const str = 'schooeal'; const findLongestVowel = (str = '') => { let cur = 0; let max ...

Read More

crypto.createDiffieHellmanGroup() Method in Node.js

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

The crypto.createDiffieHellmanGroup() method creates a predefined Diffie-Hellman group using well-known parameters. This is an alias for crypto.getDiffieHellman() and provides a secure way to establish shared secrets between parties. Syntax crypto.createDiffieHellmanGroup(name) Parameters name − A string specifying the predefined group name (e.g., 'modp1', 'modp2', 'modp5', 'modp14', 'modp15', 'modp16', 'modp17', 'modp18'). Return Value Returns a DiffieHellman object that can generate keys and compute shared secrets. Example 1: Basic Usage with modp1 Create a file with name − diffieHellmanGroup.js and copy the below code snippet. After creating ...

Read More

How to show ProgressBar in ReactNative?

Shilpa S
Shilpa S
Updated on 15-Mar-2026 988 Views

ProgressBar is a way to tell users that the content will be available in sometime. It can best be used when you submit something to the server and wait for the server to respond. To work with the progress bar component install react-native-paper module using npm. The command to install react-native-paper is − npm install --save-dev react-native-paper Basic Syntax The basic component of progress bar is as follows− To work with Progress Bar you need to import it from react-native-paper as follows − import { ProgressBar} ...

Read More

How to set the width of stroke of Rectangle using FabricJS?

Rahul Gurung
Rahul Gurung
Updated on 15-Mar-2026 549 Views

In this tutorial, we are going to learn how to set the width of stroke of a Rectangle using FabricJS. Rectangle is one of the various shapes provided by FabricJS. In order to create a rectangle, we will have to create an instance of fabric.Rect class and add it to the canvas. The strokeWidth property allows us to specify the width of a stroke for an object in pixels. Syntax new fabric.Rect({ strokeWidth: Number }); Parameters ...

Read More

What are Architecture Flux Components in JavaScript?

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

Flux is a JavaScript application architecture pattern developed by Facebook for building scalable web applications. Originally designed for React applications, Flux provides a unidirectional data flow pattern that makes application state more predictable and easier to debug. The Flux architecture consists of four main components that work together to manage data flow in a predictable way. Core Flux Components Flux architecture is built around four key components that ensure unidirectional data flow: Actions − Plain JavaScript objects that describe what happened in the application Dispatcher − Central ...

Read More

Validate Tutorialspoint URL via JavaScript regex?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 259 Views

To validate a TutorialsPoint URL using JavaScript, you can use regular expressions to check if the URL matches the expected domain pattern and extract specific parts of the URL. Regular Expression Pattern The regex pattern /^https?:\/\/(tutorialspoint\.com)\/(.*)$/ breaks down as follows: ^ - Start of string https? - Matches "http" or "https" :\/\/ - Matches "://" (tutorialspoint\.com) - Captures the domain (escaped dot) \/ - Matches forward slash (.*)$ - Captures everything after the domain until end of string Example function validateTutorialspointURL(myURL) { var regularExpression = /^https?:\/\/(tutorialspoint\.com)\/(.*)$/; ...

Read More

Extract arrays separately from array of Objects in JavaScript

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

Suppose, we have an array of objects like this − const arr = [{ name : 'Client 1', total: 900, value: 12000 }, { name : 'Client 2', total: 10, value: 800 }, { name : 'Client 3', total: 5, value : 0 }]; We are required to write a JavaScript function that takes in one such array and extracts a separate array for each object property. Therefore, ...

Read More

Convert number to characters in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 15-Mar-2026 7K+ Views

In JavaScript, converting numbers to characters is commonly done using ASCII/Unicode values. JavaScript provides the built-in String.fromCharCode() method to convert numeric values to their corresponding characters. The String.fromCharCode() Method The String.fromCharCode() method converts Unicode values to characters. Each number represents a specific character in the ASCII/Unicode table. Syntax String.fromCharCode(num1, num2, ..., numN) Example: Single Number to Character const n = 65; const c = String.fromCharCode(n); console.log(c); console.log("Number 72 becomes:", String.fromCharCode(72)); console.log("Number 101 becomes:", String.fromCharCode(101)); A Number 72 becomes: H Number 101 becomes: e In this ...

Read More

Primality test of numbers in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 591 Views

A prime number (or a prime) is a natural number greater than 1 that cannot be formed by multiplying two smaller natural numbers. All other natural numbers greater than 1 are called composite numbers. A primality test is an algorithm for determining whether an input number is prime. We are required to write a JavaScript function that takes in a number and checks whether it is a prime or not. Basic Primality Test Algorithm The most efficient approach is to check divisibility up to the square root of the number, skipping even numbers after checking for 2. ...

Read More
Showing 15841–15850 of 61,297 articles
Advertisements