Working on a game and I want to have the specific variable appear and be printed in my alert feature if a user types in the name of the variable. How can I do that?
class Enemy {
constructor(health, strength) {
this.health = health;
this.strength = strength;
var Charizard = (350,100);
var Venusaur = (250,200);
var Blastortle = (200,250);
var Pikachu = (110,275);
}
}
var chosenEnemy = prompt("Choose enemy to battle");
if (chosenEnemy != 'Charizard' && chosenEnemy != 'Vensaur' && chosenEnemy != 'Blastortle' && chosenEnemy != 'Pikachu') {
alert("choose a valid enemy");
}
alert(Enemy.health + " " + Enemy.strength);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…