--- id: 5d80d67021b11cdaa3f6b167 title: Part 116 challengeType: 0 dashedName: part-116 --- # --description-- The conditional operator, also called the ternary operator, can be used as a one line if-else expression. The syntax is: `condition ? statement-if-true : statement-if-false;`. Change the if-else expression from the last challenge to use the ternary operator instead. Here is an example: ```js if (age >= 18) { adultFunction(); } else { kidFunction(); } // The above if-else expression does the same thing as the following line age >= 18 ? adultFunction() : kidFunction(); ``` # --hints-- See description above for instructions. ```js assert( attack .toString() .match( /^\s*\}\s*else\s*if\s*\(\s*monsterHealth\s*\<\=\s*0\s*\)\s*\{\s*fighting\s*\=\=\=\s*2\s*\?\s*winGame\(\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 ```