Thursday 28 April 2016

Booleans - The Complete Node JS Developer Course

Booleans


Lesson 15 is all about Booleans! The taught part of the lesson was very clear and easy to follow; the independent task, however, was a bit vague, but the instructor did that deliberately. He wants us to get used to doing independent research and solving our own problems, because that will be an everyday part of life as a programmer. The internet has a wealth of forums and documentation that we need to get used to referencing.

I have uploaded the boolean task to GitHub. I did the task over two days, and here's the final product:


The task was to create a function that takes a boolean value and flips it. So if the value is false, the function will return true, and vice versa. Because I set the value of the variable isValid to false, the final outcome should be true.

The extra challenge was to create a function that only accepted booleans. That's where the bit of research came in, the fruit of which is on line 5. We hadn't come across typeof booleanVar in the course, so the journey continues to be very interesting and engaging.

As always, the instructor goes through everything and demonstrates a possible solution, so you're never completely stuck. I have modified my solution accordingly, because initially it was very lengthy, but now it's a little more elegant.

No comments:

Post a Comment