Found 6685 Articles for Javascript

JavaScript Program for Maximum Sum of i*arr[i] Among all Rotations of a Given Array

Prabhdeep Singh
Updated on 30-Mar-2023 11:46:07

111 Views

In this article, we will implement the JavaScript program for the Maximum sum of i*arr[i] among all the rotations of the given array. Here i*arr[i] expression indicates that we have to maximize the sum of all the elements of the array by taking the product of them with the current position. We can rotate the given array elements in the left of the right position to get the maximum answer. For this problem, we will see a complete code and a deep explanation. Introduction to Problem In this problem, we are given an array and if we multiply all the ... Read More

JavaScript Program for Maximum Product Subarray

Prabhdeep Singh
Updated on 30-Mar-2023 11:44:39

245 Views

A subarray is part of an array formed by removing some or no prefixes of the array and removing some or no suffix elements of the given array. We will try to find the subarray that will contain the elements, and by multiplying all of them, we can get the maximum value. We will implement the code with the explanation. In this article, we will implement a JavaScript program for the Maximum product subarray. Introduction to Problem In this problem, we are given an array and we have to pick any subarray from the given array, but the issue is ... Read More

JavaScript Program for Maximize Elements Using Another Array

Prabhdeep Singh
Updated on 30-Mar-2023 11:42:46

126 Views

In this article, we are going to implement a JavaScript program for Maximizing elements using another array. We are given two arrays and have to pick some elements from the second array and replace the elements of the first array. We will see the complete code to implement the concepts that will be discussed. Introduction to Problem In this problem, we are given two arrays and we have to make all the elements of the first array maximum as possible or simply we have to make the sum of all elements of the first array maximum. We can pick elements ... Read More

JavaScript Program for Markov Matrix

Prabhdeep Singh
Updated on 30-Mar-2023 11:40:36

116 Views

A matrix is a kind of 2-D array, which is in the form of some number of rows, and for each row, there is the same number of columns and by the row and column number, we can get the element at any particular index. For the Markov matrix, each row's sum must equal 1. We are going to implement a code to create a new Markov matrix and find if the currently given matrix is a Markov matrix or not. Introduction to Problem In the given problem, we have to write a code that will produce the Markov ... Read More

JavaScript Program for Longest Subsequence of a Number having Same Left and Right Rotation

Prabhdeep Singh
Updated on 30-Mar-2023 11:37:09

141 Views

We will implement a code to find the longest subsequence of a given number that has the same left and right rotation in the JavaScript programming language. The left and right rotation of a given number means, for left rotation we have to move the left-most digit of the number to the end position or the rightmost position. Similarly, for the right rotation, we have to move the right-most digit of the number to the first position or the leftmost position. We will see the complete code with the implementation. Introduction to Problem In this problem, we are given a ... Read More

JavaScript Program for Left Rotation and Right Rotation of a String

Prabhdeep Singh
Updated on 30-Mar-2023 11:36:01

760 Views

Left rotation of a string means anti-clockwise movement of the given number of characters from the prefix side and add them to the suffix side. Similarly, right rotation of a string means clockwise movement of the characters of the given string but just opposite of the left rotation and given number of characters are picked from the suffix and added to the prefix of the string. In this article, we will implement the JavaScript program for the left rotation and right rotation of a given string. Introduction to Problem In this problem, we are given a string and a number. ... Read More

JavaScript Program for the Least Frequent Element in an Array

Prabhdeep Singh
Updated on 30-Mar-2023 11:33:39

477 Views

In this program, we are given an array of integers or elements and we have to return the element which presents the least numbers of the time in the array, and if there is more than one least frequent number present we can return any one of them which we are going to see in the article below. Introduction to Problem In the given problem we have to find the least frequent element in an array. Here we have given an array with duplicate numbers and here we have to count the occurrence of each element and among all of ... Read More

JavaScript Program for the Last duplicate element in a Sorted Array

Prabhdeep Singh
Updated on 30-Mar-2023 11:31:04

267 Views

In this program, we are given a sorted array with duplicate elements and we have to traverse the for loop and return the index of the last duplicate element present in the array and also the duplicate number, which is going to see in the article below. Introduction to Problem In the given problem we have to find the last duplicate element in a sorted array. Duplicate means the number is present more than one time, so here we have given a sorted array (increasing order) from which we have to find the index of the last duplicate elements and ... Read More

How to convert Title to URL Slug using JavaScript?

Aman Gupta
Updated on 24-Mar-2023 12:22:56

1K+ Views

Overview The conversion of a title to URL Slug is also known as to “Slugify” a title. An URL Slug refers to a title which is descriptive by itself and is easy to read. It is attached to the URL of a page which tells about the current page as the slug is self-descriptive. So to convert a title to slug using JavaScript can be achieved using certain JavaScript functions such as toLowerCase(), replace(), trim(). Algorithm Step 1 − Create a HTML page with two input tags and add the id attribute in it as “title” and “urlSlug” respectively, ... Read More

How to convert speech to text using JavaScript?

Aman Gupta
Updated on 24-Mar-2023 12:16:55

14K+ Views

Overview To convert the spoken words to the text we generally use the Web Speech API’s component that is “SpeechRecognition”. The SpeechRecognition component recognizes the spoken words in the form of audio and converts them to the text. The spoken words are stored in it in an array which are then displayed inside the HTML element on the browser screen. Syntax The basic syntax used in is − let recognization = new webkitSpeechRecognition(); We can also use SpeechRecognition() instead of webkitSpeechRecognition() as webkitSpeechRecognition() is used in chrome and apple safari browser for speech recognition. Algorithm Step 1 ... Read More

Advertisements