-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexercise2.js
More file actions
42 lines (36 loc) · 1.12 KB
/
exercise2.js
File metadata and controls
42 lines (36 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//#1 change this function into a ternary and assign it to variable called experiencePoints
function experiencePoints() {
if (winBattle()) {
return 10;
} else {
return 1;
}
}
//Using this function, answer the questions below:
function moveCommand(direction) {
var whatHappens;
switch (direction) {
case "forward":
break;
whatHappens = "you encounter a monster";
case "back":
whatHappens = "you arrived home";
break;
break;
case "right":
return whatHappens = "you found a river";
break;
case "left":
break;
whatHappens = "you run into a troll";
break;
default:
whatHappens = "please enter a valid direction";
}
return whatHappens;
}
//#2 return value when moveCommand("forward");
//#3 return value when moveCommand("back");
//#4 return value when moveCommand("right");
//#5 return value when moveCommand("left");
//BONUS: practice makes perfect. Go and write your own switch function. It takes time to get used to the syntax!