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
TextDecoder and TextEncoder in Javascript?
TextEncoder and TextDecoder are modern JavaScript APIs that handle text encoding and decoding operations. TextEncoder converts strings to UTF-8 bytes, while TextDecoder converts byte arrays back to strings with support for multiple character encodings. TextEncoder Overview TextEncoder converts JavaScript strings into UTF-8 encoded Uint8Array. It only supports UTF-8 encoding and provides a simple encode() method. TextEncoder Example ...
Read MoreCounting how many times an item appears in a multidimensional array in JavaScript
We have a nested array of strings and we have to write a function that accepts the array and a search string and returns the count of the number of times that string appears in the nested array. Therefore, let's write the code for this, we will use recursion here to search inside of the nested array and the code for this will be − Example const arr = [ "apple", ["banana", "strawberry", "dsffsd", "apple"], "banana", ["sdfdsf", "apple", ["apple", ["nonapple", "apple", ["apple"]]]] ...
Read MoreCheck whether a number is a Fibonacci number or not JavaScript
We are required to write a JavaScript function that takes in a number and returns a boolean based on the fact whether or not it comes in the fibonacci series. For example − If the function call is like this − fibonacci(12); fibonacci(89); fibonacci(55); fibonacci(534); Then the output should be − false true true false What is the Fibonacci Series? The Fibonacci series is a sequence where each number is the sum of the two preceding ones: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
Read MoreDelete duplicate elements based on first letter – JavaScript
We need to write a JavaScript function that removes duplicate strings based on their first letter, keeping only the first occurrence of each starting letter. For example, if we have an array like: const arr = ['Apple', 'Jack', 'Army', 'Car', 'Jason']; We should keep only one string for each starting letter. Since 'Apple' and 'Army' both start with 'A', we keep only 'Apple' (first occurrence). Similarly, 'Jack' and 'Jason' both start with 'J', so we keep only 'Jack'. Problem with Direct Array Modification The original approach has a bug - modifying an array ...
Read MoreHow to submit an HTML form using JavaScript?
In this tutorial, we will learn how to submit an HTML form using JavaScript. JavaScript provides multiple approaches to handle form submission, from direct programmatic submission to validation-based submission with user feedback. We will discuss two main methods for submitting HTML forms: Using the Form submit() Method Using Manual Validation Let us explore both methods with practical examples. Using the Form submit() Method The submit() method programmatically submits a form without requiring user interaction with the submit button. This method takes no parameters and returns no value—it ...
Read MoreHow to set the width of the left border with JavaScript?
In this tutorial, we will learn how to set the width of the left border with JavaScript. The border property specifies the boundary of an element. It defines the border style, color, and width. To modify individual border sides, we use specific properties like borderLeftWidth for the left border. The DOM Style borderLeftWidth property allows you to set or return the width of an element's left border. Before setting the border width, ensure the element has a border style defined. Using the borderLeftWidth Property The borderLeftWidth property accepts values like "thin", "medium", "thick", or specific measurements ...
Read MoreHTML5/CSS align list-items depending on other columns mutual height
When working with HTML5 and CSS, aligning list items across columns of different heights is a common layout challenge. Using CSS Flexbox provides an elegant solution for creating flexible, responsive columns with proper alignment. Basic Flex Layout Structure The wrapper container uses display: flex to create a flexible row layout: .wrap { display: flex; } .wrap .col { flex: 1 0 33%; } The flex: 1 0 33% property means each column will grow equally, never shrink below its content size, and start with a ...
Read MoreWhat are the ways to include style sheet rules in an HTML document
There are three main ways to include CSS styles in an HTML document: inline styles using the style attribute, internal stylesheets using the element, and external stylesheets using the element. Method 1: Inline Styles Inline styles are applied directly to HTML elements using the style attribute: Inline Styles Example Inline Styled Heading This paragraph has inline styles. Method 2: Internal Stylesheets Internal stylesheets are defined within the element in the document's ...
Read MoreCalculating average of an array in JavaScript
Calculating the average of an array is a common task in JavaScript. The average is computed by summing all elements and dividing by the array length. Basic Formula Average = (Sum of all elements) / (Number of elements) Method 1: Using forEach Loop Calculate Array Average Calculating Average of an Array Array: Calculate Average ...
Read MoreGet minimum number without a Math function JavaScript
We need to find the smallest number from a set of numbers without using JavaScript's built-in Math.min() function. This requires implementing our own comparison logic. Approach Using While Loop We'll iterate through all numbers and keep track of the smallest value found so far, updating it whenever we encounter a smaller number. Example const numbers = [12, 5, 7, 43, -32, -323, 5, 6, 7, 767, 23, 7]; const findMin = (...numbers) => { let min = Infinity, len = 0; while(len < numbers.length) { ...
Read More