Nikitasha Shrivastava

Nikitasha Shrivastava

163 Articles Published

Articles by Nikitasha Shrivastava

Page 14 of 17

Return the element that appears for second most number of times in the array JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 18-May-2023 389 Views

In the given problem statement, our task is to return the element that appears for the second most number of times in the array with the help of Javascript. So to solve this problem we will use map function to count the frequency of every element. Understanding the problem statement The given problem is to get the element in the given array which appears for the second most number of times. Suppose we have an array of integer numbers [1, 3, 3, 4, 4, 4] so the function should return 3 as we can see in the array 3 is ...

Read More

Remove number from array and shift the remaining ones JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 18-May-2023 204 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

Recursive loop that prints an inverted count in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 18-May-2023 469 Views

In the given problem statement, we have to print an inverted count with a recursive loop and code with the help of Javascript. So basically we have to print the count in inverted count or we can say in descending order. What is Recursive technique ? The recursive technique is an approach that involves solving a problem by breaking it into smaller pieces of the same problem till a base case is reached. This function calls itself with different arguments in order to achieve the required output. This is commonly used when the solution to a problem depends on ...

Read More

Random whole number between two integers JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 18-May-2023 269 Views

In the given problem statement, we have to find the whole number between two integers with the help of Javascript functionalities. So for doing this task we can use some in-built functions of javascript and also for loop to get the required result. Understanding the problem statement The problem statement is to write a function in Javascript that will help to find out the whole random number between two integer numbers. For example if we want to print a random number between 1 to 5 so there are 5 possibilities, the number can be 1, 2, 3, 4, 5. So ...

Read More

Queue Reconstruction by Height in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 18-May-2023 263 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

Numbers smaller than the current number JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 18-May-2023 615 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

Nth element of the Fibonacci series JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 18-May-2023 1K+ Views

In this problem statement, our aim is to find the nth element in the fibonacci series with the help of Javascript functionalities. To solve this problem we will use a recursive technique. Understanding the problem statement The problem is to write a function in Javascript that will help find the nth number in the fibonacci sequence. For example, if we want to know the 3rd number in the fibonacci series then the 3rd number is 2. What is the Fibonacci series? The Fibonacci sequence is the chain of numbers in which each number is the sum of previous numbers. The ...

Read More

N consecutive odd numbers JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 18-May-2023 761 Views

In this problem statement, our target is to print the n consecutive odd numbers and implement this problem with the help of Javascript functionalities. So we can solve this problem with the help of loops in Javascript. Logic for the given problem In the given problem statement we have to design a program to generate a given number of consecutive odd numbers starting from 1. It will be done by creating an empty array to store the odd numbers and then using a loop which will run n times to add every odd number to the created array. The loop ...

Read More

Maximum difference between a number JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 18-May-2023 394 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

Masking a string JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 18-May-2023 6K+ Views

The above problem statement is about masking a substring within a string with the help of asterisks in Javascript. So we have to create a function to get the string with some hidden characters. Understanding the problem statement In the above problem statement we have to mask a substring within a string with the help of asterisks in Javascript. Masking a given string means we have to replace the certain characters in the given string with some other characters. Normally the asterisks used to hide sensitive information such as passwords, credit card numbers and other confidential data. Logic for the ...

Read More
Showing 131–140 of 163 articles
Advertisements