All Questions
Tagged with algorithm javascript
6,705
questions
1
vote
2
answers
300
views
How to fix color bar in canvas?
I have JavaScript code that draws vertical bars and changes their color based on the average music frequency. I tried to change the color of each bar to match the color of the previous bar, but I got ...
0
votes
3
answers
74
views
How do i remove two of the same item from an array [closed]
im working my way through the odin project and looking at for loops and different methods. Im trying to find a way to pass this test :
test('removes multiple of the same value', () => {
expect(...
1
vote
0
answers
28
views
How to achieve smooth paint strokes like Adobe Illustrator in Javascript?
I'm looking for techniques or algorithms to make my webapp's strokes smooth like in those drawing apps.
Currently I have achieved calligraphy style brush but there are still jagged edges.
My Stroke ...
0
votes
6
answers
121
views
Checking if a word in string contains a palindrome
I want to find if a string contains a palindrome word. An example would be hellosannasmith contains a palindrome word and should return sannas, however givemefood should return none. I first tried it ...
2
votes
2
answers
120
views
Is there a way to search an array of arrays for matching properties and if they match, make sure they aren't in adjacent positions?
I have been wracking my brain for a week on this problem and would appreciate any help or suggestions. I have a form that collects the users first name, last name and song. It stores those values in ...
1
vote
1
answer
38
views
How do I conditionally deep merge objects in JavaScript with multiple keys
The project I am working on is a trilingual dictionary. I have a database of words, and each word contains (among other things) an array of spelling variations and an array of objects representing ...
-1
votes
1
answer
48
views
Coin Change II : To take a value or not to
The problem goes like this:
You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money.
Return the number of ...
0
votes
1
answer
43
views
Error: PKCS#12 uses unsupported MAC algorithm: 1.2.804.2.1.1.1.1.2.1
Unable to sign pdf file with .pfx certificate due to error. Error: PKCS#12 is using an unsupported MAC algorithm: 1.2.804.2.1.1.1.1.2.1, this certificate is from Diia service, they also provided me ...
0
votes
1
answer
123
views
Checking odds and evens
I do not understand this question.
I create a function or callable object that takes an integer as an argument and returns "Even" for even numbers or "Odd" for odd numbers. The ...
1
vote
0
answers
55
views
Shortest path in Directed Acyclic Graph. Is topological Sort Really needed?
Here's a famous problem:
Given a Directed Acyclic Graph of N vertices from 0 to N-1 and a 2D Integer array(or vector) edges[ ][ ] of length M, where there is a directed edge from edge[i][0] to edge[i][...
0
votes
2
answers
71
views
Function that use Sliding Window isn`t working
The function should return the length of the maximum substring in which there are no duplicate characters, but the program runs for an infinite amount of time
function findMaxLength(str) {
let right ...
-2
votes
2
answers
60
views
How to find the optimal products with the lowest price amount with the highest quantity?
I tried to write a function for myself but it somehow incorrectly outputs the final result:
function findOptimalProducts(products, budget) {
const getPrice = (priceString) => parseFloat(...
3
votes
1
answer
67
views
Return correct value at each iteration- dynamic programming
The problem goes like this:
Geek is going for n day training program. He can perform any one of these three activities Running, Fighting, and Learning Practice. Each activity has some point on each ...
0
votes
4
answers
120
views
Create an array using item from different array
I need to create a new array of objects with 12 item (months & value) on it but it must check if the month exist on other array. If it exist it will push onto the array if not it will have a value ...
1
vote
2
answers
76
views
How to determine which day the 1st of the current month falls on based on current date in JS without using new Date()
Given that 18 May 2024 is a Saturday, how do you determine which day 1 May falls on without using new Date()?
Edit:
The answer I provided should work for all the programming languages that has index 0 ...