Efficient learning via efficient code vs. simply passing

Efficient learning via efficient code vs. simply passing


I am looking for the opinion of others. I posted a similar question elsewhere but in relation to a more specific question but figured it might be potentially useful to beginners if they run across this.

Question: If a piece of code passes a challenge in one browser but does not in another because the code could be refactored to be more efficient, do you think a learning beginner should focus on writing code that passes all browsers or settle for passing a challenge with less-than-ideally-efficient code?


Considering that the challenge tests were designed in such a way that at least one efficient algorithm exists which will pass the tests on all browsers, then I would say you need to learn to write a more efficient algorithm. Your current solution is iterating too many times and can be solved with fewer iterations with a different algorithm.


Going from a working (or working-ish) solution to a better solution is a good skill and habit to build.