A javascript question

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 :+1:. 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.


Thanks and i will definitely look at the MDN pages that site is already a huge tool. yea I really didn’t know where to post this.

Keep practicing and learning JavaScript and you will soon be able to solve past challenges in less than 5 lines of code.

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.

thanks for the input

There are two book that I’ve found helpful. “HTML5, Javascript and JQuery: A software engineer learns”, by Dane Cameron. He’s an experienced programmer who started learning the material in the book title late in life, and so he has perceptions that may be unique. Also, he provides a perspective on the technology compared with other technologies that he’s very knowledgeable about.

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.

In addition, I found this helpful in dealing with prototypes and other things. “The principles of object-oriented javascript” by Nicholas C. Zakas.

Learning javascript piecemeal from the web has its drawbacks, unless you go through a coherent tutorial. The books are more complete. The web is good as a reference for statements.

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.

He also has a book on javascript and jquery, which I am supposed to receive today, so I will update this review in about a week after I get a feeling for it.


Hi, I hope I am not annoying you with the following suggestion: Try to give your future posts more descriptive titles. “A JavaScript Question” can be pretty much anything, as a title this is way too generic in my opinion. Avoid generic titles such as “question”, “newbie question”, “simple question”, “simple CSS question” and so forth. They do not tell somebody who is reading the title if he or she is likely able to answer your question or not.

If the only thing I know about a question is that it has to do with JavaScript in some way or other, there is, like, an eighty percent chance that I cannot answer it and reading the question is just a waste of time. If I know it has to do with the “Everything Be True” challenge beforehand, this increases my chances of being able to give a meaningful answer dramatically, so I’m far less likely to waste my time, and far more likely to click on the question.

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.

I would like to recommend Gordon Zhu’s How to be great at asking coding questions.

1 Like

thanks i will definitely be checking these out

I just checked your github, and I can guarantee you that you are qualified to answer like 99% of JS questions on this site :wink:

And it’s never a waste of time to read questions, at least you become aware of things you don’t know.


I understand what you are saying but I titled it that because it wasn’t mainly about that exercise. It was more about JavaScript in general.


There is certainly nothing wrong with your title (or else I would have changed it :slight_smile: ); however, you could be a bit more specific:

  • How to get better at Javascript Algorithms
  • Javascript Question: My algorithm sucks (note: I am not saying yours did, again, every solution is good. I am just saying that I have seen titles like this before)
  • Javascript everything be true: how can I do it better?
  • My algorithms are not as good as others
  • Looking for advice on solving algorithms. ex: everything be true

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.

1 Like

Thank you for the compliment.