Found 9321 Articles for Object Oriented Programming

Check whether we can form string2 by deleting some characters from string1 without reordering the characters of any string - JavaScript

Nikitasha Shrivastava
Updated on 11-Aug-2023 16:51:30

176 Views

In this given statement our task is to determine whether we can form string2 by removing some characters from the string1 without changing the order of the characters of any string with the help of Javascript functionalities. Understanding the problem The problem at hand is to check that the second string can be formed using the first string without changing the order of both the strings. For example suppose we have two strings as: s1 = "apple" s2 = "ale" Output - true So the output for the above strings should be true because the ... Read More

Pick out numbers from a string in JavaScript

Nikitasha Shrivastava
Updated on 16-Aug-2023 13:03:03

129 Views

In the given problem we are required to find out the numbers from a given string with the help of Javascript functionalities. So we will use regular expressions and some predefined functions of Javascript. Understanding the Problem The problem at hand is to find the numbers from the given string in Javascript. This task can be useful sometimes. To accomplish this task we will use regular expressions and also some string manipulation functions of Javascript. So in simple terms we will be given a string in this string there will be some integer or other type of number ... Read More

Finding all duplicate numbers in an array with multiple duplicates in JavaScript

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

627 Views

In the given problem statement we have to find all duplicate numbers in an array with multiple duplicates with the help of Javascript functionalities. So we will use basic Javascript tot solve this problem. Understanding the Problem The problem at hand is to find the duplicate numbers in an array with the help of JavaScript. So we will basically extract all the numbers which are appearing more than once in the given array. And in response we will get the array of repeated numbers. For example, suppose we have an array as [1, 1, 4, 8, 2, 2, ... Read More

Cumulative sum at each index in JavaScript

Nikitasha Shrivastava
Updated on 14-Aug-2023 15:24:42

695 Views

In the given problem statement we have to calculate the cumulative sum at each index with the help of Javascript functionalities. So we will use basic Javascript syntax and functions to solve this problem. What is Cumulative sum ? The cumulative sum is also known as running sum or prefix sum. So this sum is the calculation of the sum of a series of numbers up to a given index or position. In this process the numbers iteratively add each number in the series to the sum of the previous items. So the resultant new series in ... Read More

Finding the largest and smallest number in an unsorted array of integers in JavaScript

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

4K+ Views

In the given problem statement we have to find the largest and smallest number in an unsorted array of integers with the help of Javascript functionalities. So we will use an array of integers and find the smallest and largest number from the array. Understanding the Problem The problem we have is to find the largest and smallest values in an unsorted array of integers. So in this task we will see a solution in Javascript. With the help of it we can determine the largest and smallest numbers in an array without sorting the array. For example ... Read More

Factorize a number in JavaScript

Nikitasha Shrivastava
Updated on 14-Aug-2023 15:35:11

453 Views

In the given problem statement we are required to factorize the given number with the help of Javascript functionalities. So we will use loops and basic mathematics to factorize the given number. Understanding the Problem The problem at hand is to factorize the given number with the help of Javascript. So the factorization means we will have to find all the prime factors of a number. The prime factors are the prime numbers which can divide the given number without leaving a remainder. So with the help of finding the prime factors we will be able to ... Read More

Pair whose sum exists in the array in JavaScript

Nikitasha Shrivastava
Updated on 16-Aug-2023 12:39:25

184 Views

In this article we will see how to find a pair of items in an array which has sum equals to a specific target number. So we will use JavaScript to implement the algorithm. Understanding the Problem The problem at hand is to find the pair of numbers in the array whose sum is equal to the given target value. And the target value should also be there in the array. Or we can say that we have to identify pairs (a, b) where a + b = c and c is also present in the array. ... Read More

Get the closest number out of an array in JavaScript

AmitDiwan
Updated on 10-Dec-2020 08:00:27

112 Views

We are required to write a JavaScript function that takes in an array of Numbers as the first argument and a single number as the second argument.The function should find and return that number from the array which is closest to the number specified by the second argument.For example −const arr = [34, 67, 31, 53, 89, 12, 4]; const num = 41;Then the output should be 34.ExampleFollowing is the code −const arr = [34, 67, 31, 53, 89, 12, 4]; const num = 41; const findClosest = (arr = [], num) => {    let curr = arr[0];   ... Read More

Check if string ends with desired character in JavaScript

Nikitasha Shrivastava
Updated on 11-Aug-2023 16:30:50

124 Views

In the given problem statement we are required to check if the string ends with the desired character with the help of Javascript functionalities. So we will use basic functions and syntax of Javascript to solve the problem. Understanding the problem The problem at hand is to check if a given string is ending with the given specific character in Javascript. For example suppose we have a string as Hello World! and we have to check if the exclamation ‘!’ mark is present at the end of the string or not. So after comparing with the string the ... Read More

Comparing integers by taking two numbers in JavaScript

Nikitasha Shrivastava
Updated on 14-Aug-2023 14:44:55

526 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 use basic Javascript to solve this problem. Understanding the Problem The problem at hand is to compare the two integers given. This operation is a common operation when it comes to sorting the data. In this task we will find how to compare two integers and check their relationship with the help of Javascript. For example, we have two integers like 10 and 20. So we can say that 10 ... Read More

Advertisements