Found 6710 Articles for Javascript

Maximum difference between a number JavaScript

Nikitasha Shrivastava
Updated on 18-May-2023 15:01:39

336 Views

In this problem statement, our task is to write the function for finding the maximum difference between a number in an array with the usage of Javascript functionalities. So we will use a nested loop to get the difference between two numbers. Understanding the problem statement The above problem statement is saying to find the maximum difference between any two numbers in the given array of integer numbers. In simple terms we have to find the largest possible difference between any two numbers of the array in which the larger number appears after the smaller number. Suppose we have an ... Read More

Fetch Numbers with Even Number of Digits JavaScript

Nikitasha Shrivastava
Updated on 18-May-2023 12:15:53

437 Views

In the given problem statement our task is to write the function for fetching the numbers with an even number of digits with the help of Javascript. For solving this task we will use a for loop and push every even number in the array. Understanding the problem statement The problem statement is to write a function which will take an array of numbers as input and return the array for containing only numbers that have an even number of digits. For example if we have an input array is [1 ,2 , 3, 4, 5] the function should return ... Read More

Numbers smaller than the current number JavaScript

Nikitasha Shrivastava
Updated on 18-May-2023 15:30:45

549 Views

In the given problem statement we have to find the smaller numbers than the current number with the help of Javascript. So for doing this task we will be keeping track of the items and decrement the current number by one to get the desired result. Understanding the problem statement The problem statement is asked to write a function which will take an array of integers as input and will return the array of the same length in which every element shows the count of the numbers in the given array which are smaller than the respective item. For example ... Read More

JavaScript Total subarrays with Sum K

Nikitasha Shrivastava
Updated on 14-Aug-2023 18:34:25

434 Views

In this problem statement, our task is to write the function for getting the total subarrays with sum K with the help of Javascript. So for doing this task we will use basic functionality of Javascript. Understanding the problem statement The problem statement is to create a function which will take an array of integers and a target sum K. So after processing the calculation it will return the total number of subarrays in the array with a sum of K. A subarray can be defined as a continuous series of items in the array. For example suppose ... Read More

Split a range of number to a specific number of intervals JavaScript

Nikitasha Shrivastava
Updated on 18-May-2023 16:08:39

3K+ Views

In this problem statement, our task is to write the function splitting a range of numbers to a specific number of intervals with the help of Javascript. So for doing this task we will have to give start, end and the intervals. Understanding the problem statement The problem statement is saying to create a function which can split a range of numbers into a specific number of intervals. And the inputs will be starting and ending numbers of the range and the desired number of intervals. So the outcome should be the array of subarrays which shows each interval. These ... Read More

Reversing array without changing the position of certain elements JavaScript

Nikitasha Shrivastava
Updated on 18-May-2023 15:46:44

566 Views

In this problem statement, our aim is to write the function for reversing the array without changing the position of certain elements with the help of Javascript. So for doing this task we will be keeping track of the indexes of the preserved elements. . Understanding the problem statement The problem is for creating a function to reverse an array in Javascript but with certain elements in the array must not be changed their position. So the positions of these items should be the same in both the original and reversed arrays. For example let's say we have an array ... Read More

Remove number from array and shift the remaining ones JavaScript

Nikitasha Shrivastava
Updated on 18-May-2023 15:38:02

157 Views

In this problem statement, our task is to write a function to remove numbers from the array and shift the remaining elements with the help of Javascript functionalities. So we will use basic for loop to remove one element from the array and shift the remaining elements to get the output array. Understanding the problem statement The problem statement is saying to create a function which can remove a given number from an array and shift the remaining items to fill the gap of the removed item. For example we have given an array [1, 2, 3, 4, 5] and ... Read More

Lucky Numbers in a Matrix in JavaScript

AmitDiwan
Updated on 25-Nov-2020 07:01:27

612 Views

Given a m * n matrix of distinct numbers, we have to return all lucky numbers in the 2-D array (matrix) in any order.A lucky number is an element of the matrix such that it is the minimum element in its row and maximum in its column.For example − If the input array is −const arr = [    [3, 7, 8],    [9, 11, 13],    [15, 16, 17] ];Then the output should be −const output = [15];because 15 is the only lucky number since it is the minimum in its row and the maximum in its column.ExampleThe code ... Read More

Queue Reconstruction by Height in JavaScript

Nikitasha Shrivastava
Updated on 18-May-2023 15:32:07

221 Views

In this problem statement, our task is to write a function for queue reconstruction by height with the help of Javascript. So basically we have to arrange the given array data by height. Understanding the problem statement The problem statement says to write a function in Javascript with the help of we can arrange the queue as per the height. This will be done by queue reconstruction. The Queue Reconstruction by height problem is done by arranging a queue of persons based on their height and the number of people in front of them who are taller or have ... Read More

Get key from value in JavaScript

Nikitasha Shrivastava
Updated on 18-May-2023 14:00:10

2K+ Views

In the given problem statement we have to write a function which will help to get the key of the given value with the usage of Javascript functionalities. So basically in Javascript if we want to access the keys or value from the given object we can access it by dot notation or bracket notation. Understanding the problem statement The problem statement says that we have to find a key from a value in a Javascript object. That means we are given a Javascript object and a value so we need to find the corresponding key which maps to that ... Read More

Advertisements