--- id: 5d7e06728360d21c6826a9b8 title: Part 102 challengeType: 0 dashedName: part-102 --- # --description-- An `else` statement can be conditional with an `else if` statement. At the end of the `if` statement, add an `else if` statement to check if `monsterHealth` is less than or equal to zero. Inside the `else if` block, call the `defeatMonster()` function. Here is an example of an `if` statement with `else if` and `else`: ```js if (num > 15) { return "Bigger than 15"; } else if (num < 5) { return "Smaller than 5"; } else { return "Between 5 and 15"; } ``` # --hints-- See description above for instructions. ```js assert( attack .toString() .match( /^\s*if\s*\(\s*health\s*\<\=\s*0\s*\)\s*\{\s*lose\(\s*\);?\s*\}\s*else if\s*\(\s*monsterHealth\s*\<\=\s*0\s*\)\s*\{\s*defeatMonster\(\s*\)\;?\s*\}/m ) ); ``` # --seed-- ## --before-user-code-- ```html RPG - Dragon Repeller
XP: 0 Health: 100 Gold: 50
Monster Name: Health:
Welcome to Dragon Repeller. You must defeat the dragon that is preventing people from leaving the town. You are in the town square. Where do you want to go? Use the buttons above.
``` ## --after-user-code-- ```html ``` ## --seed-contents-- ```html ``` # --solutions-- ```html ```