Found 8895 Articles for Front End Technology

How to show some custom menu on text selection?

Shubham Vora
Updated on 05-Apr-2023 15:37:29

605 Views

In some text editors, when you select the text, it shows the menu to edit texts and provides functionalities like justifying text, aligning text, increasing the text size, changing colour, etc. Microsoft word is the best example of it. In Microsoft word, when you select any text, it shows the custom horizontal menu to perform some actions on the text. This tutorial will use JavaScript to create a custom menu on the text selection. Syntax Users can follow the syntax below to show some custom menu on text selection. let coOrdinates = document.querySelector(".content").getBoundingClientRect(); let posX = clientX - Math.round(coOrdinates.left) + ... Read More

How to show pagination in ReactJS?

Shubham Vora
Updated on 05-Apr-2023 16:31:34

474 Views

The pagination allows users to show content on different pages. For example, we have thousands of data and want to show that to users on a single webpage. It will look worse if we show thousands of data on a single page, as users must scroll through all data to reach the last data. So, to solve the issue, pagination comes into the picture. We can show a particular number of data on a single page and create a total number of pages according to the total data available. Gmail is the best example of pagination, it shows 50 emails ... Read More

JavaScript Program for Maximum and Minimum in a Square Matrix

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

183 Views

To find the maximum or minimum element, we have to focus on the number of comparisons we are going to make and which method will be efficient to choose for comparisons: the one that compares elements with if-else statements or one which comes as in-built. We will see the complete code implementation with the explanation. In this article, we are going to implement a JavaScript program for the maximum and minimum elements present in a given square matrix. Introduction to Problem This problem is very simple, but then going into deep will bring some good highlighted concepts that are worth ... Read More

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

127 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

478 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

Advertisements