--- id: 5d6f6bfc7c812010bf3327cc title: Part 53 challengeType: 0 dashedName: part-53 --- # --description-- What if the player doesn't have enough gold to buy health? Put all the code in the `buyHealth` function inside an `if` statement. Here is an example of an `if` statement inside a function: ```js function checkMoney() { if (condition) { console.log("You have money!"); } } ``` Note: For now you should use the word "condition" inside the `if` statement but we'll be changing that next. # --hints-- See description above for instructions. ```js assert( buyHealth .toString() .match( /if\s*\(\s*condition\s*\)\s*\{\s*(gold|health|goldText|healthText)/ ) && buyHealth.toString().match(/gold\s*\-\=\s*10\;?/) && buyHealth.toString().match(/health\s*\+\=\s*10\;?/) && buyHealth.toString().match(/goldText\.innerText\s*\=\s*gold\;?/) && buyHealth.toString().match(/healthText\.innerText\s*\=\s*health\;?/) ); ``` # --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 ```