javascript-algorithms | JS algorithm problems & data structures | Learning library
kandi X-RAY | javascript-algorithms Summary
kandi X-RAY | javascript-algorithms Summary
A repository of my solutions to JS algorithm problems & data structures and preparing for interview. Caution advised. :open_hands: :sunglasses:
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of javascript-algorithms
javascript-algorithms Key Features
javascript-algorithms Examples and Code Snippets
Community Discussions
Trending Discussions on javascript-algorithms
QUESTION
I'm learning a bit of JavaScript, but I'm having hard time understanding the lesson on FreeCodeCamp about the recursion countdown (link).
In the lesson, there this initial example. But I'm confused on how it operates:
...ANSWER
Answered 2021-Jun-01 at 17:26Here what the array looks like inside of each function call if this helps:
QUESTION
I am trying to complete the "Map the Debris" freecodecamp challenge https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/map-the-debris, and I think I've gotten it. It works from my PC's code editor, but when I copy/paste into the website area the conditions don't satisfy.
How do I best debug this?
My code is
...ANSWER
Answered 2021-Feb-05 at 02:40You have to parse to int the orbSec variable
Just replace this line:
QUESTION
This is a follow up to my questions on the Arguments Optional Challenge in Freecodecamp (see below0:
I have now satisfied 5/6 conditions of the challenge, except for when the input is addTogether(2,([3])), which returns '23' as a string instead of the correct 'undefined'.
If the [3] is an array, and an array is an object, shouldn't my checkNum function work to label that as undefined? Where was the string generated?
my code now:
...ANSWER
Answered 2021-Feb-04 at 05:28We can declare functions in 2 ways, the regular way:
QUESTION
Hello guys I am having some issues understanding this challenge from FreeCodeCamp< i just did all the steps that I was told to do on the challange but I can just get it to work, here is the link
And here is my solution
...ANSWER
Answered 2020-Dec-15 at 19:13I am sharing my solution which is slightly different from yours. Compare it to your own. You will see that I only return inside my for loop when I get a positive match , otherwise I let the loop run. This is the biggest difference. You need to let the loop run fully and then through some mechanism keep track of the missing conditions . I have used two different variables to track the missing conditions here.
QUESTION
This regex has to match passwords that are greater than 5 characters long, do not begin with numbers, and have two consecutive digits.
All the test cases are passing the regex test.
My regex is /(?=^[a-z]+\d{2,})(?=\w{5,})/
I have to use two positive lookaheads to solve this problem to pass the tests.
But astr1on11aut is not passing the test. Why?
Link to problem- https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/regular-expressions/positive-and-negative-lookahead
...ANSWER
Answered 2020-Nov-10 at 07:25If you are not limited to using a single regex, I suggest splitting this into multiple tests in your host language (e.g. JavaScript):
QUESTION
im studying JavaScript and im trying to solve the problem in this test exercise: FreeCodeCamp Record Collection
I can't understand why it doesnt work. The object details and the problem description are in the link above.
...ANSWER
Answered 2020-Oct-23 at 16:07Let's take a look at this line:
QUESTION
I'm just trying to learn javascript regex and have been stuck on this problem for a while.
I need to match patterns, some examples below:
...ANSWER
Answered 2020-Jul-30 at 07:34Have alook at anchors
Add a $ if it is per line: /^(\d+)(\s)\1\2\1$/
QUESTION
I have a question about javascript.
At first, the result of the code below is "-1 Hold", but I'm wondering why does the part where I put mark ① automatically loops with the next arguments?
I was expecting that the function processes through of it and put the result with only one argument, then goes to the next arguments. So I expected "1 Bet", "1 Bet", "-1 Hold", "0 Hold", "-1 Hold" would be output as a result.
I couldn't find explanation about this since yesterday to now.. I'd be happy if somebody helps me.
*This is the URL of the task I'm talking about.
Here is the code.
...ANSWER
Answered 2020-Jul-01 at 14:03If you are using dev console to test it, it is simple. Only last command return value is shown (Not last line).
You should do something like
QUESTION
ANSWER
Answered 2020-Jun-27 at 23:05you needed to return "resultDisplayArray(arr)" instead of "resultDisplayArray", and place a "let" in front of "element"
QUESTION
I just finished the FreecodeCamp.com quiz Intermediate Algorithm Scripting: Smallest Common Multiple.
The code is working fine for the test cases they give ([1, 5]
, [5, 1]
[23, 18]
and [1, 13]
) but if I use a bigger range I also have to edit the code and increase the stop condition for the for
-loop, and when I remove the stop condition from the loop, it gives an error.
ANSWER
Answered 2020-Jun-26 at 23:57Going to explain a little of the code; what we do first is to sort the array since it is an array of two numbers, after we sort it, we need to create a new array to store the path from the first element to the second one; we define the diference between the greatest and the smallest number in order to create a for to store the path, after we store the path; we define two functions for finding the grand common divisor and the Least Common Multiple; after that we use a reduce to get the Value of the LCM. Hope this helps you, the algorithm of the gcd is based on Euclidean Division
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install javascript-algorithms
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page