From 9dedc71c550e02c4382a2c15a7e8876b1dc44100 Mon Sep 17 00:00:00 2001 From: Joe Roland Date: Mon, 21 Jan 2019 13:43:41 -0500 Subject: [PATCH] update(guide): Added Ternary Operator Example (#29032) --- .../miscellaneous/the-return-early-pattern/index.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/guide/english/miscellaneous/the-return-early-pattern/index.md b/guide/english/miscellaneous/the-return-early-pattern/index.md index 3e5ba57037b..feaed19216b 100644 --- a/guide/english/miscellaneous/the-return-early-pattern/index.md +++ b/guide/english/miscellaneous/the-return-early-pattern/index.md @@ -70,4 +70,13 @@ We can further refactor this function to only use one if statement. Check it out } return true; - } \ No newline at end of file + } + +### Bonus: Ternary Operator + +The function can be even further refactored to use a single line of code by using a ternary operator: + + function willItBlend(someObject) { + return typeof someObject !== 'object' || someObject.blendable !== 'It will blend' ? false : true; + } +