Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
No, it actually calls all 4 operations, due to the fact that the object initialization has to resolve it's properties during runtime
so by calling cases[operation], you're just returning 1 of 4 already calculated operations
whole numbers, integers, and decimals, floats, are different kinds of numerical data. There is no need to worry about floats because that isnt the data being tested.
as the kata specifically says it accepts only booleans as inputs, then yes thats what they want.
could add it but null undefined etc are not booleans
The idea is that booleans only have two values. true and false. If the entered boolean is true it outputs "Yes" if the entere boolean is false it outpits "no" There isnt even any calculation required here. It just directly returns Yes or No depending on whats entered.
Thank you. Had no clue what half of this meant.
i saw some folks saying this runs all 4 operations but that isnt true right? the key [operation] is defining the condition for the code block within cases resulting in only the code matching the condition being executed? Essentially replacing switch(operation) if i understand it correctly.
It's certainly readable, if you've got the time.
I had a similar function, but declared a variable first. Makes sense the whole thing could just be returned.
it's not a completely ridiculous solution though.
Honestly think height ** 2 is better. I'll be remembering that!