Found 6710 Articles for Javascript

Finding the largest prime factor of a number in JavaScript

Nikitasha Shrivastava
Updated on 14-Aug-2023 17:45:04

1K+ Views

In the given problem statement we have to find the largest prime factor of a number with the help of Javascript functionalities. So we will solve this problem with the help of basic functionalities of Javascript. Understanding the Problem The problem at hand is to find the largest prime factor of a given input number. So the prime factor of a number is the prime number which can divide the given number without leaving the remainder. Our task is to find the largest prime factor which is the prime factor with the highest value. For example let's say ... Read More

Finding all the Longest Strings from an Array in JavaScript

Nikitasha Shrivastava
Updated on 14-Aug-2023 17:36:07

786 Views

In the given problem statement we have to find all the longest strings from an array with the help of Javascript functionalities. So basically this task can be done by getting the length of each string and then comparing these lengths with the maximum length. Understanding the Problem The problem at hand is to find the longest strings from an array in Javascript. So we will have an array of strings and our main task is to identify the strings which have the maximum length and show them as a new array. For example: suppose we have an ... Read More

JavaScript: Adjacent Elements Product Algorithm

Nikitasha Shrivastava
Updated on 22-Jan-2025 00:45:23

798 Views

In this article, we will learn to calculate the adjacent elements product with the help of Javascript functionalities. This problem is often asked in coding interviews or algorithm challenges, and it tests one's understanding of array manipulation and performance optimization. Problem Statement Given an array of integers, your task is to return the largest product that can be obtained by multiplying any two adjacent numbers in the array. For example − Input [5, 1, 2, 3, 1] Output 6 The adjacent elements are (5, 1), (1, 2), (2, 3), and (3, 1). The largest product is 6 (from 2 * ... Read More

Absolute Values Sum Minimization in JavaScript

Nikitasha Shrivastava
Updated on 11-Aug-2023 16:42:09

604 Views

In the given problem statement we have to find the absolute value for minimization of the sum in the given array with the help of Javascript functionalities. So we will use basic mathematics for solving the problem. Understanding the problem The problem at hand is to find the absolute values for minimization of the sum. This is the basic problem to solve in mathematics and computer science. This program involves finding a number from the given array which minimizes the sum of the absolute difference between that number and the other item in the array. Logic ... Read More

Sum of even Fibonacci terms in JavaScript

Nikitasha Shrivastava
Updated on 16-Aug-2023 17:02:26

562 Views

In the given problem statement we have to calculate the sum of even fibonacci numbers with the help of Javascript functionalities. So for solving this task we will use basic functionalities of the language. Understanding the Problem The problem at hand is to calculate the sum of even fibonacci numbers or items up to the given limit of the fibonacci number. As you may know, the fibonacci sequence is a series of numbers in which every number is the sum of the two previous numbers. The series usually starts from 0 and 1. So in this problem our ... Read More

Finding sum of multiples in JavaScript

Nikitasha Shrivastava
Updated on 14-Aug-2023 17:39:01

2K+ Views

In the given problem statement we have to find the sum of the multiples of the given input number within the given range with the help of Javascript functionalities. So we will use a loop to iterate through the numbers from the starting range to the ending range. Understanding the Problem The problem at hand is to find the sum of multiples of the given number in the given range. So in this problem we have to calculate the sum of all the numbers that are divisible by the given number. For example: suppose we have a ... Read More

Sort an integer array, keeping first in place in JavaScript

Nikitasha Shrivastava
Updated on 16-Aug-2023 16:53:58

236 Views

In the given problem statement we have to sort the given integer array but we have to keep the first item in place and sort the remaining items with the help of Javascript functionalities. So we will use some predefined functions of Javascript to solve the problem. Understanding the Problem The problem at hand is to get the sorted array of integer numbers in Javascript and the main operation in this task is to keep the first item intact in its original position. Or we can say we have to rearrange the items in the array so that ... Read More

Wait for complex page with JavaScript to load using Selenium.

Debomita Bhattacharjee
Updated on 30-Nov-2020 10:34:40

3K+ Views

We can wait for a complex page with JavaScript to load with Selenium. After the page is loaded, we can invoke the Javascript method document.readyState and wait till complete is returned.SyntaxJavascriptExecutor js = (JavascriptExecutor)driver; js.executeScript("return document.readyState").toString().equals("complete");Next, we can verify if the page is ready for any action, by using the explicit wait concept in synchronization. We can wait for the expected condition presenceOfElementLocated for the element. We shall implement the entire verification within the try catch block.Exampleimport org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; import org.openqa.selenium.JavascriptExecutor; public class PageLoadWt{    public static void main(String[] args) { ... Read More

Capturing JavaScript error in Selenium.

Debomita Bhattacharjee
Updated on 30-Nov-2020 10:29:16

2K+ Views

We can capture Javascript error in Selenium. This type of error appears at the Console Tab on opening the Developer tools in the browser. This can occur due to some functional issue in the page or due to extra logs which may cause performance issues.We can handle the Javascript errors with the driver object and manage method.Exampleimport org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import java.util.List; import java.util.ArrayList; import org.openqa.selenium.logging.LogEntries; import org.openqa.selenium.logging.LogEntry; import org.openqa.selenium.logging.LogType; import java.util.logging.Level; import java.util.Set; public class JavascrptLogErs{    public static void main(String[] args) {       System.setProperty("webdriver.chrome.driver",       "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe");       WebDriver ... Read More

Find the Exact Individual Count of Array of String in Array of Sentences in JavaScript

Nikitasha Shrivastava
Updated on 14-Aug-2023 17:14:18

292 Views

In the given problem statement we have to find the exact individual count of the array of strings in the array of sentences with the help of Javascript functionalities. So we will solve using the for loops to get the required result. Understanding the Problem The problem at hand is to find the exact individual count for each string in an array of sentences with the help of Javascript. We will be given an array or string and an array of sentences. So we have to find out how many times every string is appearing in the given ... Read More

Advertisements