From d90b204f780acf8015164a8fca18f8162abdbb6e Mon Sep 17 00:00:00 2001 From: Diego Torres Date: Sat, 6 Jun 2020 23:18:49 -0500 Subject: [PATCH] Update phrasing on "Comparison with ||" The phrase `zero becames 100.` make me think that there is a variable `zero` defined when there is not. --- 1-js/02-first-steps/12-nullish-coalescing-operator/article.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/1-js/02-first-steps/12-nullish-coalescing-operator/article.md b/1-js/02-first-steps/12-nullish-coalescing-operator/article.md index ee06d5cb..56365f7b 100644 --- a/1-js/02-first-steps/12-nullish-coalescing-operator/article.md +++ b/1-js/02-first-steps/12-nullish-coalescing-operator/article.md @@ -60,9 +60,9 @@ alert(height || 100); // 100 alert(height ?? 100); // 0 ``` -Here, `height || 100` treats zero height as unset, same as `null`, `undefined` or any other falsy value. So zero becames `100`. +Here, `height || 100` treats zero height as unset, same as `null`, `undefined` or any other falsy value. So the alert shows `100`. -The `height ?? 100` returns `100` only if `height` is exactly `null` or `undefined`. So zero remains "as is". +The `height ?? 100` returns `100` only if `height` is exactly `null` or `undefined`. So the alert shows the height value `0` "as is". Which behavior is better depends on a particular use case. When zero height is a valid value, that we shouldn't touch, then `??` is preferrable.