If you just copy and paste code from Stack Overflow, you are just cheating yourself. If you took a plain language or pseudo-code written algorithm and converted it to JavaScript to solve the challenge, then I would say you took information on a better approach to solve a problem and implemented a solution on your own.

In the latter, you actually learn something and are not cheating yourself.

If you design a new algorithm that works, great. But this isn’t a theoretical math course.

If you understand the Euclid algorithm, then write code for it, you’ve learned.

Frankly, even if you copy the code from wiki, or stack, and it works, you have still learned what solution solves the problem, now you can study why. You can go back and a) immediately rewrite it without referencing b) do it again in 6 hours c) do it again tomorrow, etc until you learn it