23.04.2013 Views

javascript

javascript

javascript

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 3 ■ OPERATORS<br />

88<br />

Figure 3–21. Determining whether all five comparisons are true<br />

Let’s make && happy and change the third comparison “not less than” to “less than.” As Figure 3–22<br />

displays, since all five comparisons are true, overall the && chain returns true. Hurray!<br />

var muffin = {<br />

oatFlour: [1/3, "cup"],<br />

barleyFlour: [1/3, "cup"],<br />

pastryFlour: [1 + 1/3, "cup"],<br />

freshlyGroundNutmeg: [1/4, "tsp"],<br />

saigonCinnamon: [1/2, "tsp"],<br />

seaSalt: [1/4, "tsp"],<br />

soda: [1, "tsp"],<br />

tartar: [1, "tsp"],<br />

mapleBrownCow: [1 + 1/2, "cup"],<br />

boysenberries: [2, "cup"],<br />

choppedPecans: [1/3, "cup"]<br />

};<br />

muffin.mapleBrownCow[0] < muffin.boysenberries[0] &&<br />

muffin.oatFlour[0] === muffin.barleyFlour[0] &&<br />

muffin.freshlyGroundNutmeg[0] < muffin.saigonCinnamon[0] &&<br />

muffin.choppedPecans[0] muffin.barleyFlour[0];<br />

// true

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!