Last active
January 2, 2016 11:18
-
-
Save wolftatsu/8295259 to your computer and use it in GitHub Desktop.
JavaScript
変数の初期化
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//条件分岐 | |
var direction = "right"; | |
// 初期化してはじめて、型をnumberとして認識する | |
var x = 0, y = 0; | |
switch (direction) { | |
case "right": | |
x = x + 10; | |
break; | |
case "left": | |
x = x - 10; | |
break; | |
case "up": | |
y = y - 10; | |
break; | |
case "down": | |
y += 10; // y = y + 10 | |
break; | |
default; | |
// 例外処理 | |
break; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment