Javascript Articles - Page 198 of 534

Algorithm to get the combinations of all items in array JavaScript

Nikitasha Shrivastava
Updated on 18-May-2023 10:49:18

4K+ Views

In this problem statement, our task is to get the combinations of all items in an array with the help of Javascript functionalities. So for doing this task we can use a recursive approach that iteratively adds items to a running list of combinations. Understanding the problem statement The problem statement is to write a function in Javascript that will help to find out the combinations of all the elements in an array and create a separate array to show these combinations. For example, if we have an array [ 1, 2 ] so the combinations of this array will ... Read More

Nth element of the Fibonacci series JavaScript

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

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

Using Sieve of Eratosthenes to find primes 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

Spiraling the elements of a square matrix JavaScript

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

335 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

Reversing the words within keeping their order the same JavaScript

Nikitasha Shrivastava
Updated on 18-May-2023 15:51:03

1K+ Views

In this problem statement, our aim is to reverse the words within keeping their order in the same order with the help of Javascript functionalities. So for solving this problem we can use traditional for loops and also built-in methods or Javascript. Understanding the problem statement The problem statement is aiming for a function which takes a string as input and will return a new string in which the order of the words should remain intact but in reversed direction. For example, we have given a string "Hello World" so the function should return "olleH dlroW", here "Hello" is reversed ... Read More

Checking for string anagrams JavaScript

Nikitasha Shrivastava
Updated on 18-May-2023 11:55:13

391 Views

In this problem statement, our aim is to check for string anagrams with the help of Javascript functionalities. So for solving this problem first we need to understand the problem in simple terms. Understanding the problem statement We have given a string as an input string and our main aim is to check if the string is an anagram string or not. If it is anagram then return true otherwise return false. What do you mean by anagrams? In the given problem statement there is the usage of the word anagram!! Let’s first understand the meaning of this word. Anagram ... Read More

Function to find out palindrome strings JavaScript

Nikitasha Shrivastava
Updated on 18-May-2023 13:39:42

234 Views

In this problem statement, our aim is to create a function to find out that the given string is palindrome with the help of Javascript functionalities. So for solving this problem first we need to understand the problem in simple terms. Understanding the problem statement We have given a string as an input string and our main aim is to check if the string is a palindrome string or not. If it is palindrome then return true otherwise return false. What do you mean by palindrome? In the given problem statement there is the usage of the word palindrome !! ... Read More

Implementing counting sort in JavaScript

Nikitasha Shrivastava
Updated on 18-May-2023 14:35:46

1K+ Views

In the given task, our aim is to create a counting sorting technique and implement this problem with the help of Javascript functionalities. What is the Counting Sort? The counting sort is a process for sorting a data set of objects as per the keys. It works by counting the number of items that have different key values and finding the position of each object in the sorted output. The idea of counting sort is to place the items directly into its correct place in the output array. In the beginning of the algorithm we need to find ... Read More

Function to reverse a string JavaScript

Nikitasha Shrivastava
Updated on 18-May-2023 13:51:03

609 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. Understanding the problem statement The given problem is stating that we have given a string to which we have to reverse the string. In simple terms we can say that if we have the string “Hello”, the reverse of this string will be “olleH”. Logic for the given problem For solving the above problem we need to have the basic knowledge of ... Read More

Sorting numbers according to the digit root JavaScript

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

266 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

Advertisements