How do you print text if a variable doesn't exist?

https://perchance.org/18wavqtc4u#edit

My goal with this seems simple: if "family" is not a listed value under the random enemy chosen, print "N/A" instead. However, I have zero clue as to how that could be done. I'm looking for a method that would still work well on a larger scale because I plan to apply this fix to this other generator I made: https://perchance.org/pikmin-enemy-generator#edit

1 points · 2 comments · view on lemmy.world

2 Comments

Yeetus_McGee@lemmy.world · 1 pts · 173d (1 reply)

Update: I believe I figured it out! This line seems to achieve the effect I'm going for: [w.family = w.family || "N/A", ""]

However, touching up the code has led me to a new question... How might I go about keeping the randomize button from jittering while the image loads?

qinerous@lemmy.world · 1 pts · 173d

To prevent the button from shaking, set a specific height for Output

<div style="height:80px;">
 <p id="outputName">[w = enemy.selectOne]</p>
</div>

just add this tags around of your <p id="outputName">[w = enemy.selectOne]</p>