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
Returning acronym based on a string in JavaScript
We need to write a JavaScript function that creates an acronym from a string by taking the first letter of each word that starts with an uppercase letter. The function should build and return the acronym based on the string phrase provided as input. While constructing the acronym, the function should only consider words that start with an uppercase letter. Problem Statement Given a string like "Polar Satellite Launch Vehicle", we want to extract the first letter of each capitalized word to form "PSLV". Input: 'Polar Satellite Launch Vehicle' Output: 'PSLV' Solution ...
Read MoreCounting all possible palindromic subsequence within a string in JavaScript
Palindrome Sequence A palindromic subsequence is a sequence that reads the same from front and back. For instance, 'aba', 'madam', 'did' are all valid palindromic sequences. A subsequence can be contiguous or non-contiguous - we can skip characters but maintain their relative order. We need to write a JavaScript function that counts all possible palindromic subsequences within a string. The input string contains only characters 'a', 'b', 'c', and 'd'. Problem Example For the string 'bccb', the palindromic subsequences are: Input: "bccb" Palindromic subsequences: 'b', 'c', 'c', 'b', 'cc', 'bb', 'bcb', 'bccb' Total count: ...
Read MoreCounting prime numbers that reduce to 1 within a range using JavaScript
Problem We need to write a JavaScript function that takes a range array of two numbers and returns the count of prime numbers whose squared sum of digits eventually reduces to 1 through repeated calculation. For example, 23 is a prime number and: 2² + 3² = 4 + 9 = 13 1² + 3² = 1 + 9 = 10 1² + 0² = 1 + 0 = 1 Since the process eventually reaches 1, the number 23 qualifies as a "happy prime". Understanding the Solution The solution involves three key functions: ...
Read Morecrypto.createSign() Method in Node.js
The crypto.createSign() method creates and returns a Sign object that uses the specified algorithm for generating digital signatures. You can use crypto.getHashes() to get the names of all available digest algorithms. Sign instances can also be created using signature algorithms like 'RSA-SHA256' in some cases. Syntax crypto.createSign(algorithm, [options]) Parameters The parameters are described as follows: algorithm – The algorithm name to be used while creating the sign object/instance (e.g., 'SHA256', 'RSA-SHA256'). ...
Read MoreHow to display dropdown in ReactNative?
React Native provides the Picker component (now deprecated) and modern alternatives for creating dropdown selections. This guide covers both approaches. Basic Picker Syntax The traditional Picker component follows this structure: Import the Picker component from React Native: import { Picker } from 'react-native' Picker Properties Property Description enabled Boolean value. If false, picker is disabled and user cannot select items. itemStyle Styling to be applied to picker items. ...
Read MoreCreating a Simple Calculator using HTML, CSS, and JavaScript
A student grade calculator is a web application that takes subject grades as input and calculates the overall percentage and letter grade. This interactive tool provides instant feedback on academic performance using HTML for structure, CSS for styling, and JavaScript for calculations. The percentage calculation formula is: Percentage = (Total Marks Scored / Total Maximum Marks) × 100 How It Works The calculator follows these steps: User enters marks for different subjects through HTML input fields JavaScript function retrieves and validates the input values ...
Read MoreHow to Create a Parallax Effect using HTML, CSS, and JavaScript?
In this article, we are going to learn about parallax effects and how to create them using HTML, CSS, and JavaScript. We will be using the mouse-move event to show the parallax effect. During the parallax effect, two different images move in parallel to each other. Both the images will be working parallel and making the same transitions. The only difference will be they move in the opposite directions. Parallax effects are used for making websites better in terms of User Experience and enhancing the interactivity level of the website. We can move the foreground and the background images ...
Read MorePadding a string with random lowercase alphabets to fill length in JavaScript
We are required to write a function that takes in two arguments, first is a string and second is a number. The length of string is always less than or equal to the number. We have to insert some random lowercase alphabets at the end of the string so that its length becomes exactly equal to the number and we have to return the new string. Example Let's write the code for this function — const padString = (str, len) => { if(str.length < len){ ...
Read MoreJavaScript - Accept only numbers between 0 to 255 range?
In JavaScript, validating user input to accept only numbers within a specific range is a common requirement. This is particularly useful for form validation, color values (RGB components), or any scenario where you need to ensure numeric input falls within defined bounds. In this article, we will explore different methods to accept only numbers between 0 and 255 range using JavaScript. This range is commonly used for RGB color values, where each color component must be between 0 and 255. Using if else Condition The if/else statement executes a block of code when a condition is true, ...
Read MoreFilter an array containing objects based on another array containing objects in JavaScript
Suppose we have two arrays of objects like these − const arr1 = [{id:'1', name:'A'}, {id:'2', name:'B'}, {id:'3', name:'C'}, {id:'4', name:'D'}]; const arr2 = [{id:'1', name:'A', state:'healthy'}, {id:'3', name:'C', state:'healthy'}]; We are required to write a JavaScript function that takes in two such arrays. Our function should return a new filtered version of the first array (arr1 in this case) that contains only those objects with a name property that are not contained in the second array (arr2 in this case) with the same name property. Therefore, the output, in this case, should look like ...
Read More