Javascript Articles

Page 138 of 534

Factorize a number in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 14-Aug-2023 869 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

Cumulative sum at each index in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 14-Aug-2023 967 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

Convert string with separator to array of objects in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 14-Aug-2023 455 Views

In this article we will discuss algorithm and complexity for converting string with separator to array of objects with the help of Javascript functionalities. For doing this task we will use split and map functions of Javascript. Understanding the problem statement The problem statement says to write a function which can convert a given string with the given separator into an array of objects in Javascript. For example, if we have a string "name1, name2, name3" and a separator ", " then we have to convert these strings into an array of objects which looks like: [{value: ...

Read More

Comparing integers by taking two numbers in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 14-Aug-2023 1K+ 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

Common Character Count in Strings in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 14-Aug-2023 721 Views

In the given problem statement we are required to find the common characters count for the given strings 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 find the common characters between the two given strings. So for solving this problem we will determine how many characters they have in common. For example suppose we have two strings like "abaac" and "baaaa" so in these two strings we can see there are 2 common characters which are 'a' and 'b'. So the ...

Read More

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

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 11-Aug-2023 304 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

Absolute Values Sum Minimization in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 11-Aug-2023 664 Views

In the given problem statement we have to find the absolute value for minimization of the sum in the given array with the help of Javascript functionalities. So we will use basic mathematics for solving the problem. Understanding the problem The problem at hand is to find the absolute values for minimization of the sum. This is the basic problem to solve in mathematics and computer science. This program involves finding a number from the given array which minimizes the sum of the absolute difference between that number and the other item in the array. Logic ...

Read More

Check if string ends with desired character in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 11-Aug-2023 257 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

Average with the Reduce Method in JavaScript

AmitDiwan
AmitDiwan
Updated on 11-Aug-2023 1K+ Views

In the given problem statement, our aim is to get the average of all the items with the help of the reduce method of Javascript. So for doing this task we will create a function and give an array as a parameter. Understanding the problem statement We have given a task to calculate the average value of the given items in the array. And we have to use the reduce method which is a predefined method of Javascript. For example if we have an array as [1, 2, 3, 4, 5], so the average value of the ...

Read More

Algorithm to add binary arrays in JavaScript

AmitDiwan
AmitDiwan
Updated on 11-Aug-2023 829 Views

In this problem statement, our target is to add two binary arrays with the help of Javascript. So we will break down the problem step by step to ensure understanding. What is the Binary array ? A binary array is an array that represents a binary number. In a binary number system we have only two possible digits, 0 and 1. The binary array will have the elements which can only be 0s and 1s. Every item in the array will represent a bit of the binary number. For example we have a binary array [1, ...

Read More
Showing 1371–1380 of 5,338 articles
« Prev 1 136 137 138 139 140 534 Next »
Advertisements