Using Sieve of Eratosthenes to Find Primes in JavaScript

Nikitasha Shrivastava
Updated on 18-May-2023 16:13:04

1K+ Views

In this problem statement, our aim is to apply a sieve of eratosthenes algorithm to find out the prime numbers with the help of Javascript functionalities. So in our program we will implement a function to find primes numbers up to a given limit. Understanding the problem statement The problem statement is to write a function in Javascript that will work for finding the prime numbers up to a given number. And for implementing this function we will use the Sieve of Eratosthenes algorithm. What is the Sieve of Eratosthenes Algorithm ? The Sieve of Eratosthenes is an easy and ... Read More

Using Grep on Files That Match Specific Criteria

Prateek Jangid
Updated on 18-May-2023 16:13:02

1K+ Views

Grep (global regular expression print) command matches and searches the specific pattern in the regular expressions. This command filters and searches for a particular pattern of characters and displays them as output. It is considered one of the most useful commands on Unix / Linux-like systems for sysadmins and developers. Linux contains various types of commands and utilities to simplify every task. Unlike other operating systems, finding any file in Linux is simple because you can use the grep command to search any file. You can use the grep command to display the specific file's name that contains a particular ... Read More

Merge Sort to Recursively Sort an Array in JavaScript

Nikitasha Shrivastava
Updated on 18-May-2023 16:11:38

2K+ Views

In this problem statement, our aim is to sort an array recursively using merge sort and implement the code with the help of Javascript. So below we will discuss Merge sort and its implementation. Understanding the problem statement The problem statement is to write a function for merge sort in Javascript that will help to sort the given input array into an ascending or descending order. And we have to create a function which will sort the elements recursively. What is the recursive sorting technique? Recursion is a technique in which a function calls itself to solve a problem. When ... Read More

Split a Range of Number to Specific Number of Intervals in 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

Spiraling the Elements of a Square Matrix in JavaScript

Nikitasha Shrivastava
Updated on 18-May-2023 16:04:33

317 Views

In this problem statement, our main aim is to spiral the elements of the square matrix with the help of Javascript functionalities. There are several methods that can be used to do this task in Javascript. Understanding the problem statement The problem statement is to write a function in Javascript that will show the output as spiraling the elements of a square matrix. For example, if we have a two dimensional matrix as [1, 2] [3, 4], if we spiral the elements in clockwise direction then the output array will be [1, 2, 4, 3]. Logic for the ... Read More

Special Arrays in JavaScript

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

530 Views

In this problem statement, our task is to show working of some special arrays and their characteristics in Javascript programming. In Javascript a special array can be dependent on the given context. The special arrays can refer to different types of arrays depending on the condition and context. There are some interpretations possible: Typed arrays, Sparse arrays and Array with string keys. What is the Typed Array? In Javascript there are many built-in methods available for typed array objects. These arrays are special in the context that they represent the array of a specific type of data in it. ... Read More

Sorting Strings with Decimal Points in JavaScript

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

1K+ Views

In this problem statement, our aim is to sort strings with decimal points with the help of Javascript functionalities. So for doing this task we will use the sort and map method of Javascript. Understanding the problem statement The problem statement is to write a function in Javascript by which we can sort the given strings with decimal points. For example if we have an array of strings like [‘3.3’, ‘4.4’, ‘2.3’, ‘1.2’] so our task is to sort the given array of strings. But for sorting these strings first we need to convert it into numbers. After converting ... Read More

Sort Odd and Even Elements Separately in JavaScript

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

1K+ Views

In our problem statement we have to sort odd and even elements separately with the help of Javascript functionalities. So for doing this task we will use for loops and bubble sort for sorting odd and even numbers separately. Understanding the problem statement The problem statement is to write a Javascript function that will help to sort odd and even numbers in a given array. For example if we have an array [2, 3, 5, 4] then we will first sort even indexed elements [3, 4] and then sort the odd indexed elements in the array [2, 5]. After sorting ... Read More

Sorting Numbers According to the Digit Root in JavaScript

Nikitasha Shrivastava
Updated on 18-May-2023 15:54:54

252 Views

In this problem statement, our task is to sort numbers according to the digit root and implement this problem with the help of Javascript functionalities. So we can solve this problem with the help of loops in Javascript. What is digit root? The digit root of a given number is basically the sum of its digits. Repeat the calculation until the result is not a single digit. Let's take an example for the digit root, calculate the digit root for 1234, 1 + 2 + 3 + 4 = 10 = 1 + 0 = 1. Similarly the digit root ... Read More

Round Number Down to Nearest Power of 10 in JavaScript

Nikitasha Shrivastava
Updated on 18-May-2023 15:52:47

1K+ Views

In the provided problem statement, our task is to write the function for partial sum in an array of arrays with the help of Javascript. So here we will be given a variety of arrays and we need to compute the sum of each row and show the result. Understanding the problem statement The problem statement is asking for creating a function in Javascript which rounds down a given input number to the nearest power of 10. For example if there is an input 1365 so the output should be 1000. That is the nearest power of 10 which is ... Read More

Advertisements