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
Implementing block search in JavaScript
Block Search is a searching algorithm for sorted arrays that improves upon linear search by jumping ahead in fixed steps rather than checking every element. It combines the efficiency of skipping elements with linear search for the final location. How Block Search Works The algorithm divides the array into blocks of size √n and performs these steps: Jump through blocks of size √n until finding a block where the target might exist Perform linear search within that specific block Return the index if found, or -1 if not found Block Search ...
Read MoreBoolean Gates in JavaScript
We are required to write a JavaScript function that takes in an array of Boolean values and a logical operator. Our function should return a Boolean result based on sequentially applying the operator to the values in the array. Problem Given an array of Boolean values and a logical operator (AND, OR, XOR), we need to apply the operator sequentially to all values and return the final result. Solution Here's the implementation that handles three common Boolean operations: const array = [true, true, false]; const op = 'AND'; function logicalCalc(array, op) { ...
Read MoreRepresenting number as the power and product of primes in JavaScript
We need to write a JavaScript function that takes a positive integer and represents it as a product of prime powers. This process is called prime factorization. For a number n, our function should return a string in the format: n = "(p1**n1)(p2**n2)...(pk**nk)" Where p1, p2, p3...pk are prime numbers, n1, n2...nk are their powers, and ** represents exponentiation. Understanding Prime Factorization Prime factorization breaks down a number into its prime factors. For example, 12 = 2² × 3¹, which would be represented as "(2**2)(3)". Implementation Here's a corrected and improved implementation: ...
Read Morecrypto.getHashes() Method in Node.js
The crypto.getHashes() method returns an array containing the names of all supported hash algorithms available in Node.js. This is useful for discovering what hashing options are available in your current Node.js environment. Syntax crypto.getHashes() Parameters This method takes no parameters and returns an array of supported hash algorithm names. Return Value Returns an array of strings, where each string is the name of a supported hash algorithm. Example // Importing the crypto module const crypto = require('crypto'); // Get all supported hash algorithms const hashAlgorithms = crypto.getHashes(); ...
Read MoreHow to show a checkbox in reactnative?
Checkboxes are a common component that we often use in mobile UI. React Native provides several ways of implementing checkboxes in your applications. The core React Native package does not include checkbox support, so you need to install a third-party package to work with it. Installation The following package needs to be installed to display checkboxes: npm install react-native-paper Basic Checkbox Component The basic checkbox component structure is as follows: Important Properties Let us explore the important properties available for the checkbox component: ...
Read MoreHow to Disable Radio Buttons using JavaScript?
A radio button is an input type that allows users to select one option from multiple choices. In web forms, you may need to disable radio buttons dynamically based on user interactions or specific conditions. In this article, we will explore how to disable and enable radio buttons using JavaScript. We'll cover the disabled property and demonstrate practical examples where radio buttons are conditionally disabled. The disabled Property JavaScript provides the disabled property to control whether form elements are interactive. This boolean property can be set to true to disable an element or false to enable it. ...
Read MoreHow to Create a Video and Audio Recorder with JavaScript MediaRecorder API?
In this tutorial, you will learn how to create an audio and video recorder using JavaScript's MediaRecorder API with WebRTC technology. This allows you to capture and record media directly in the browser. What is WebRTC? WebRTC (Web Real-Time Communication) enables real-time communication capabilities in web browsers. It allows access to user devices like webcams and microphones through JavaScript APIs. The core method for accessing media devices is: navigator.mediaDevices.getUserMedia(constraints) The getUserMedia() function requests user permission to access the webcam and microphone. It returns a Promise that resolves with a MediaStream if permission is ...
Read MoreHow to show Page Loading div until the page has finished loading?
Rather than showing a blank white or black screen while loading the page, it is better to show a loading indicator, which improves the user experience of the application. Nowadays, there are many libraries available to show loading indicators. However, we can use HTML, CSS, and JavaScript to create a customized loading indicator div. In this tutorial, we will use HTML, CSS, and JavaScript to show page loading div until the page has finished loading. Use the onreadystatechange Event to Show the Loading Indicator In JavaScript, the onreadystatechange event triggers whenever the state of the web ...
Read MoreDifference of digits at alternate indices in JavaScript
In JavaScript, we can calculate the difference between the sum of digits at even indices and the sum of digits at odd indices. This is useful for various mathematical operations and data validation scenarios. Problem Statement We need to write a JavaScript function that takes a number and returns the absolute difference between the sum of digits at even positions and the sum of digits at odd positions (counting from right to left, starting at index 0). Example For the number 123456: Even indices (0, 2, 4): digits 6, 4, 2 → sum = 12 ...
Read MoreHow to filter an array from all elements of another array – JavaScript?
In JavaScript, filtering an array to exclude elements present in another array is a common task. This involves removing all elements from the first array that match any element in the second array. When storing multiple values in a single variable, arrays are used. Each element of an array has a numeric index that enables access to it. Arrays in JavaScript begin at index zero and can be modified using various methods. Using filter() with includes() (Recommended) The most straightforward approach combines filter() with includes() to exclude matching elements: ...
Read More