So i assume this is the correct place for this but im not sure. I have been working on the intermediate Algorithm challenges and I am able to solve them after due time and sometimes research to see how others approached it. But one challenge in particular sparked this question. I geuss im not looking for an answer but more of insight. the challenge “Everything Be True”. I was able to complete this challenge pretty easily after learning how to deal with the NaN argument of one of the test. After finding a work around I took a look at this page.
And I saw how simply it was solved, and that I had basically hard coded a switch statement to do what the simple
Boolean(collection[c][pre]) call did in this example. I am actively learning and trying to understand completely each challenge and I believe it is just lack of knowledge sometimes like in this example not knowing about this Boolean call. I guess what I am asking is as I continue to learn JS I assume I will get more in tune with these methods. Anyways like I stated before not looking for a direct answer but any thoughts are welcome.
I’ll link a code pen with my solution on it. If anyone wants to take a look.
The more you practice, the better you will become. No algorithm solution is a bad solution. You figured it out and got it working even if it is not as other solutions . Some of my code that I did at the start is horrid (and most of what I do now still is ;)).
Just a tip, read the suggested MDN pages (truthy, falsy, and boolean):
As a side note, I don’t think meta is the right category. It is for discussions about the forum itself, such as improvements, suggestions, what you like about it, dislike, etc. Although it really isn’t a help thread, it is a question about programming in general, so I will put it in that thread.
Many JS native functions help you do more in less code.But it doesn’t mean your solution is wrong.Actually, I think re-implementing these built-in methods is an excellent exercice and helps understand how things are working under the hood.
If you’re looking for JS clever tricks, I’ve learned many by looking at others solutions in coding sites like https://www.codewars.com/ They aren’t always good practices, but hopefully they will improve your understanding of this programming language.
Here’s an example. On p. 80 he discusses closures in inner functions, and I quote: “Surprisingly the ‘this’ inside the inner function has reverted from being the object to being the window. This is considered by most as a bug in the language (my emphasis), but it is a bug that will not be rectified since it would break legacy code.”
Frankly, this (no pun intended) by itself is worth the price of admission.
There is a very nice CSS3 book from O’Reilly: “CSS: The missing manual” by David Sawyer McFarland. Make sure you get the most recent edition. This is very complete, and even more important, the explanations are quite sensible and useful, and he provides lots of tips about details you may not get from the web.
I hope I do not come across as reprimanding. Learning how to ask the right questions the right way is a challenge in itself, and it sure is a part of the learning process we’re all going through.
Thanks for the clarification. I did not mean to imply that there was anything wrong with the OP’s original title, I only wanted to suggest to be as specific as possible in the title, in order to increase the chance that a passing commenter will pick up the issue.