Found 9326 Articles for Object Oriented Programming

Sum of all prime numbers in JavaScript

Nikitasha Shrivastava
Updated on 16-Aug-2023 17:00:15

2K+ Views

In the given problem statement we have to compute the sum of all the prime numbers with the help of Javascript functionalities. So for calculating the sum we will set the upper limit of primes numbers. Understanding the Problem The problem is to calculate the sum of all the prime numbers up to a given limit. So the prime number is a positive integer which is greater than 1 and also these numbers do not have any divisors other than 1 and itself. For example we have a limit of the primes is 10, so the prime numbers ... Read More

Finding the smallest multiple in JavaScript

Nikitasha Shrivastava
Updated on 14-Aug-2023 17:51:05

313 Views

In the given problem statement we have to find the smallest multiple of the given numbers with the help of Javascript functionalities. So we will use loops to iterate through and check the multiples of the given numbers. Understanding the Problem The problem at hand is to find the smallest multiple of the given number in Javascript. The multiple of a number is a number that can be divided evenly by that number. To solve the problem we will use a loop and iterate over the numbers until we find the smallest multiple which is divisible by all ... Read More

Parse and balance angle brackets problem in JavaScript

Nikitasha Shrivastava
Updated on 16-Aug-2023 12:52:47

800 Views

In the given problem statement we have to find whether the angle brackets in the code are balanced or not with the help of Javascript functionalities. So for solving this problem we will use a stack based approach using Javascript methods. What is a Stack-based Approach ? The stack-based approach is an algorithmic technique which involves using a data structure called stack. So the stack is a collection of items which supports two main operations: push and pop. Push operation adds an item to the top of the stack and pop removes the top item from the stack. ... Read More

Shift strings Circular left and right in JavaScript

Nikitasha Shrivastava
Updated on 16-Aug-2023 16:47:09

887 Views

The main objective for the problem statement is to perform a circular shift on the strings in Javascript. The circular shifts can be left shirt or right shift. And implement this solution in Javascript. Understanding the Problem The problem at hand is to shift the strings circularly left and right with the help of Javascript functionalities. Circular shifting means we have to move the characters of the given string in a circular manner in which the characters that are to be shifted beyond the boundaries of the string and it should reappear at the opposite end. ... Read More

Sorting alphabets within a string in JavaScript

Nikitasha Shrivastava
Updated on 16-Aug-2023 16:57:01

236 Views

In the given problem statement we are required to sort the alphabets present in the string. And implement the solution with the help of Javascript functionalities. Understanding the Problem The problem we have is to create a function in Javascript with the help of it we can sort the given alphabets in the string in alphabetical order. The main objective is to take the string as input and produce a new string with the same characters but in a sorted form. For example is we have a string like "hello" so the sorted form of this string is ... Read More

Difference between sum of square and square of sum in JavaScript

Nikitasha Shrivastava
Updated on 14-Aug-2023 15:30:13

355 Views

In the given problem statement we have to find the difference between sum of square and square of sum with the help of Javascript functionalities. So we will create two functions to do this task. Understanding the Problem The problem at hand is to calculate the sum of squares and the square of the sum for a given set of numbers in Javascript programming. The sum of squares specifies the sum of the squares of every number in the given set. On the other hand the square of the sum means summing up all the numbers in the ... Read More

Sum of all multiples in JavaScript

AmitDiwan
Updated on 25-Nov-2020 12:09:24

194 Views

We are required to write a JavaScript function that takes in a number, say n, as the first argument, and then any number of arguments following that.The idea is to sum all numbers upto n which are divided by any of the numbers specified by second argument and after.For example −If the function is called like this −sumMultiples(15, 2, 3);Then the output should be −const output = 83;Because the numbers are −2, 3, 4, 6, 8, 9, 10, 12, 14, 15ExampleThe code for this will be −const num = 15; const sumMultiple = (num, ...arr) => {    const dividesAny ... Read More

How to split sentence into blocks of fixed length without breaking words in JavaScript

Nikitasha Shrivastava
Updated on 14-Aug-2023 18:26:09

1K+ Views

In the given problem statement we have to split the given sentence into blocks of fixed length without breaking the words of the sentence. And we have to implement the solution in Javascript. Understanding the Problem The problem at hand is to split the given sentence into blocks of a fixed length without breaking its words. So we will divide the sentence into substrings of a given length and also we will ensure that the words will remain intact in every block. For example suppose we have a sentence as "You are reading this article on ... Read More

Generating desired combinations in JavaScript

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

226 Views

In the given problem statement we have to generate the desired combinations of the given inputs. And program the solution with the help of Javascript programming . Understanding the Problem In this problem, we will be given integers from 1 to 9. Each combination should be a unique collection of numbers. The function should identify all the possible combinations of size m that and these items with size m should have the sum of n. For example if the value of m is 3 and n is 6, then the combination should be [1, 2, 3]. ... Read More

Non-negative set subtraction in JavaScript

Nikitasha Shrivastava
Updated on 16-Aug-2023 12:28:08

282 Views

In the given problem statement we are presented with two arrays which contain integer values. So our aim is to find the non negative set subtraction from the two arrays. And implement the solution in Javascript. We can perform this task using the Set object and forEach method. What are the Set object and forEach method in Javascript ? Set object in Javascript The Set is an object in Javascript which is a built in data Structure introduced in ES6. This allows us to store the unique values of any type. The values can be primitive values or ... Read More

Advertisements