Is this true?
notes.jordanscales.com · 1,611 words · saved by 1 readers
That's pretty much the same code. There is no else, so we'll get to the end and return undefined - which is not true.
Is this true? Is this true? You're writing some code - maybe building out some new features - and it's time to test your work. For some reason, you named your function fn and, for some reason, you want the result to be true . describe ( "our function" , ( ) => { it ( "returns true" , ( ) => { expect ( fn ( ) ) . toBe ( true ) } ) } ) A pretty reasonable scenario, right? Let's make it unreasonable. Pretend you're the unit test, and instead of the describe and it above, I'll give you a function and you’ll tell me if it returns true when it's called. Is this true? function fn ( ) { return true }
related reading
- HackerRank - Online Coding Tests and Technical Interviewshackerrank.com
- Definability of Truth in Probabilistic Logic - Christiano 2013intelligence.org
- Control Flow - The Rust Programming Languagerust-book.cs.brown.edu
- CSC 151 - Unit Testingeikmeier.sites.grinnell.edu
- GitHub - Experience-Monks/math-as-code: a cheat-sheet for mathematical notation in code formgithub.com
- Control Flow - The Rust Programming Languagedoc.rust-lang.org
- Vacuous truth - Wikipediaen.wikipedia.org
- Program Structure :: Eloquent JavaScripteloquentjavascript.net
- Intrinsic Values Test | Discover What Your Most Important Values Are | ClearerThinking.orgprograms.clearerthinking.org
- Control Flow · Crafting Interpreterscraftinginterpreters.com
- 3. Logic - Mathematics in Lean v4.19.0 documentationleanprover-community.github.io
- JS cheat sheetprogramming-idioms.org