官术网_书友最值得收藏!

Time for action – changing the number 9 to a different number

Since myNumber is a variable, the value it stores can vary. If we change what is stored in it, the answer to the equation will change too. Follow the ensuing steps:

  1. Stop the game and change 9 to 19.
  2. Notice that when you restart the game, the answer will be 30.

What just happened?

You learned that a variable works by simple process of substitution. There's nothing more to it than that.

We didn't get into the details of the wording used to create myNumber, or the types of variables you can create, but that wasn't the intent. This was just to show you how a variable works. It just holds data so you can use that data elsewhere in your script. We'll get into the finer details of variables in Chapter 3, Variables in Detail.

Have a go hero – changing the value of myNumber

In the Inspector panel, try changing the value of myNumber to some other value, even a negative value. Notice the change in answer in the Console.

主站蜘蛛池模板: 龙岩市| 大兴区| 竹山县| 海宁市| 达日县| 通海县| 象山县| 信宜市| 建昌县| 银川市| 阳城县| 台安县| 宁夏| 宁国市| 西安市| 连南| 环江| 永泰县| 临洮县| 永嘉县| 明溪县| 东安县| 原平市| 墨脱县| 卢龙县| 临湘市| 平安县| 塔河县| 江北区| 会昌县| 响水县| 宝山区| 西城区| 乌兰浩特市| 美姑县| 莱芜市| 渑池县| 东明县| 辽源市| 民和| 托克逊县|