LEARNING JAVASCRIPT - Trang 82

• 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

Chapter 5

)

• Logical operators (

funds > 0 && funds < 100

; the double ampersand means

“and,” which we’ll learn about in

Chapter 5

)

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

Chapter 5

,

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‐

chart as shown in

Figure 4-2

.

Figure 4-2. Crown and Anchor simulation flowchart (refined)

58 | Chapter 4: Control Flow

Liên Kết Chia Sẽ

** Đây là liên kết chia sẻ bới cộng đồng người dùng, chúng tôi không chịu trách nhiệm gì về nội dung của các thông tin này. Nếu có liên kết nào không phù hợp xin hãy báo cho admin.