JavaScript Program to Find array sum using Bitwise OR after splitting given array in two halves after K circular shifts

AmitDiwan
Updated on 15-Mar-2026 23:19:01

280 Views

We will write a JavaScript program to find the sum of an array by using bitwise OR after splitting the given array into two halves after K circular shifts. Our program will perform the task by taking an array and an integer K as inputs. First, we will split the array into two halves after performing K circular shifts. Then, we will perform bitwise OR on both the halves to get a new array. Finally, we will find the sum of the new array obtained from the bitwise OR operation. Approach First, perform K ... Read More

How to convert speech to text using JavaScript?

Aman Gupta
Updated on 15-Mar-2026 23:19:01

19K+ Views

Overview To convert spoken words to text, we use the Web Speech API's SpeechRecognition component. The SpeechRecognition interface recognizes spoken audio and converts it to text. The spoken words are processed and displayed as text in HTML elements on the browser screen. Syntax The basic syntax for creating a speech recognition instance: let recognition = new webkitSpeechRecognition(); // or let recognition = new SpeechRecognition(); Note: webkitSpeechRecognition() is used for Chrome and Safari browsers, while SpeechRecognition() is the standard implementation for other browsers. Browser Compatibility Check Before implementing speech recognition, it's important ... Read More

How To Change Text Inside All HTML Tags Using JavaScript

Yaswanth Varma
Updated on 15-Mar-2026 23:19:01

1K+ Views

In this article, we are going to perform the task of changing text inside all HTML tags using JavaScript. Let's dive into the article to learn more about changing text within all HTML, but first, let's define HTML tags. What are HTML Tags An HTML tag is a segment of markup language used to denote the start and end of an HTML element in an HTML document. HTML tags, which are a component of an HTML element, assist web browsers in turning HTML documents into web pages. For getting better understanding on changing text inside all HTML ... Read More

Javascript Program to Minimize Characters to be Changed to make the Left and Right Rotation of a String Same

Shubham Vora
Updated on 15-Mar-2026 23:19:01

190 Views

In this problem, we need to find the minimum number of character changes required to make a string's left and right rotations identical. This involves understanding how rotations work and finding patterns in character positioning. Understanding Rotations The left rotation moves characters left by one position, while right rotation moves them right. For rotations to be identical, specific character patterns must exist: Odd length strings: All characters must be the same Even length strings: Characters at even positions must be identical, and characters at odd positions must be identical Problem Analysis Given a ... Read More

How to Convert JSON to ArrayBuffer in JavaScript?

Pankaj Kumar Bind
Updated on 15-Mar-2026 23:19:01

1K+ Views

In JavaScript, an ArrayBuffer is a kind of binary structure that enables the manipulation of raw binary data. While JSON represents data as strings, it is sometimes useful to convert JSON into an ArrayBuffer when working with binary APIs or when you need to optimize data transmission. In this article, we will explore two common methods for converting JSON objects into ArrayBuffers in JavaScript. Approaches to Convert JSON to ArrayBuffer Using TextEncoder: Suitable for UTF-8 encoding (recommended). Manual Conversion with DataView: Useful for handling specific binary encoding formats or custom ... Read More

JavaScript Program to Find Closest Number in Array

AmitDiwan
Updated on 15-Mar-2026 23:19:01

3K+ Views

To find closest number in array using JavaScript, we will be understanding and discussing three different approaches. We will also compare time and space complexities of all the approaches used. In this article we are having an array and a target value, our task is to find closest number to target value in array using JavaScript. User must know about JavaScript arrays, searching algorithms such as linear and binary search, sorting, loops, and conditional statements. Approaches to Find Closest Number in Array Here is a list of approaches to find closest number in array in JavaScript which ... Read More

JavaScript Program to Find Difference Between Sums of Two Diagonals

AmitDiwan
Updated on 15-Mar-2026 23:19:01

630 Views

To find difference between sums of two diagonals, we will be discussing two different approaches. We will calculate the sum of the elements present in the left and right diagonal, then we will subtract both sum values to get the difference. In this article we are having a square matrix, our task is to write a JavaScript program to find difference between sums of two diagonals. ... Read More

Building Voice-controlled Applications with JavaScript and Speech Recognition APIs

Mukul Latiyan
Updated on 15-Mar-2026 23:19:01

920 Views

Voice-controlled applications have become increasingly popular in recent years, allowing users to interact with technology through speech rather than traditional input methods. JavaScript, being one of the most widely used programming languages for web development, provides a powerful platform for building such applications. In this article, we will explore how to utilise JavaScript and Speech Recognition APIs to create voice-controlled applications. We will dive into the process of setting up speech recognition, capturing and processing user speech, and implementing voice commands in your applications. Setting Up Speech Recognition Before we start building our voice-controlled application, we need to ... Read More

JavaScript Program to Find element at given index after a number of rotations

AmitDiwan
Updated on 15-Mar-2026 23:19:01

198 Views

When working with arrays in JavaScript, we often need to find elements after rotating the array. A rotation shifts all elements in a specific direction. This program demonstrates how to efficiently find an element at a given index after performing a number of right rotations without actually rotating the array. Understanding Array Rotations A right rotation shifts all elements one position to the right, with the last element moving to the first position. For example, rotating [1, 2, 3, 4, 5] right by 2 positions gives [4, 5, 1, 2, 3]. ... Read More

How to convert Title to URL Slug using JavaScript?

Aman Gupta
Updated on 15-Mar-2026 23:19:01

1K+ Views

Overview The conversion of a title to URL Slug is also known as "Slugify" a title. A URL Slug refers to a descriptive, readable identifier attached to a page's URL that describes the content. Converting titles to URL-friendly slugs involves using JavaScript string methods like toLowerCase(), replace(), and trim(). Algorithm Step 1 − Create HTML input elements with IDs "title" and "urlSlug" for input and output, plus a button with onclick event. Step 2 − Create a convert() function to handle the transformation. Step 3 − Get the title value using document.getElementById("title").value. Step 4 − Convert to lowercase ... Read More

Advertisements