update(guide): Added Ternary Operator Example (#29032)

pull/27939/head^2
Joe Roland 2019-01-21 13:43:41 -05:00 committed by Tom
parent 0bb24ebe9d
commit 9dedc71c55
1 changed files with 10 additions and 1 deletions

View File

@ -70,4 +70,13 @@ We can further refactor this function to only use one if statement. Check it out
}
return true;
}
}
### 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;
}