• Basic arithmetic:
funds - totalBet
,
funds + winnings
• Increment:
roll++
(this is a common shorthand that just means “add one to the
variable
roll
”)
And we’ll limit our flowchart decisions to the following:
• Numeric comparisons (
funds > 0
,
funds < 100
)
• Equality comparisons (
totalBet === 7
; we’ll learn why we use three equals signs
in
)
• Logical operators (
funds > 0 && funds < 100
; the double ampersand means
“and,” which we’ll learn about in
All of these “allowed actions” are actions that we can write in JavaScript with little or
no interpretation or translation.
One final vocabulary note: throughout this chapter, we will be using the words truthy
and falsy. These are not simply diminutive or “cute” versions of true and false: they
have meaning in JavaScript. What these terms mean will be explained in
but for now you can just translate them to “true” and “false” in your head.
Now that we know the limited language we can use, we’ll have to rewrite our flow‐
.
Figure 4-2. Crown and Anchor simulation flowchart (refined)
58 | Chapter 4: Control Flow