Hello guys!

Making this system to attack and lower a players health.

this is what i’ve come up with, But im getting an error at line 247 “unexpected identifier”. Help? ? Thanks! <3

Line 247 = logPlayerAttack.push(damage);

```
var playerName;
var playerHealth;
var attackType;
var damage;
var logPlayerAttack;
var logSpiderAttack;
var flagPlayerDead;
var flagSpiderDead;
function mageFireBall() { //Fireball spell! Damage is 1 - 45.
var attackChance;
var attackDamage = 0;
attackChance = Math.floor(Math.random() * 100); // Chance calculater, Returns a number from 0 - 100
if (attackChance < 30) { // If number returned from attackChance is < 30 Runs Low damage
/* do low damage */
attackDamage = Math.round(Math.random() * 10 + 1); // Math.Round rounds the number to a whole, Math.random gives a random number from 0 to 10, + 1.
} else if(attackChance >= 30 && attackChance < 70) { // If chance is bigger or = to 30 && smaller then 70, Run medium damage.
/* do medium damage */
attackDamage = Math.round(Math.random() * (20 - 10) + 10); // Same as low just higher values
} else {
/* do high damage */
attackDamage = Math.round(Math.random() * (45 - 30) + 30); // Same as medium and low just higer values.
}
return attackDamage;
}
function mageIceBolt() { //ice Bolt spell! Damage is 5 - 38.
var attackChance;
var attackDamage = 0;
attackChance = Math.floor(Math.random() * 100); // Chance calculater, Returns a number from 0 - 100
if (attackChance < 30) { // If number returned from attackChance is < 30 Runs Low damage
/* do low damage */
attackDamage = Math.round(Math.random() * 10 + 5); // Math.Round rounds the number to a whole, Math.random gives a random number from 0 to 10, + 1.
} else if(attackChance >= 30 && attackChance < 70) { // If chance is bigger or = to 30 && smaller then 70, Run medium damage.
/* do medium damage */
attackDamage = Math.round(Math.random() * (20 - 15) + 10); // Same as low just higher values
} else {
/* do high damage */
attackDamage = Math.round(Math.random() * (45 - 35) + 30); // Same as medium and low just higer values.
}
return attackDamage;
}
// Spiders Attack
function spiderBasicAttack () {
var attackChance;
var attackDamage = 0;
attackChance = Math.floor(Math.random() * 100);
if (attackChance < 30) {
attackDamage = Math.round(Math.random() * 15 + 5);
} else if (attackChance >= 30 && attackChance < 60) {
attackDamage = Math.round(Math.random() * ( 30 - 15) + 15);
} else {
attackDamage = Math.round(Math.random() * (50 - 30) + 30);
}
return attackDamage;
}
// Default variable values, Variables we're announced at the start of the code.
var playerHealth = 100;
var spiderHealth = 100;
var damage = 0;
var logPlayerAttack = [];
var logSpiderAttack= [];
var flagPlayerDead = false;
var flagSpiderDead = false;
var flagReplay = false;
alert('Welcome to Fireball game '); // Alerts that we entered the game
var playerName = prompt('Enter your name ', "Player one");
alert('Welcome to the fireball game, You\'l need to press attack lol ');
do {
attackType = Number(prompt(playerName + 'Choose an Attack! \n 1- FireBall \n 2- IceBolt'));
while( attackType != 1 && attackType != 2) {
attackType = Number(prompt('Attack is unknown! please choose an attack\n 1- FireBall \n 2- IceBolt'));
}
switch ( attackType ) {
case 1:
damage = fireBall();
spiderHealth -= damage;
/* control spider is alive if it's dead set the flag to true */
if (spiderHealth <= 0) {
flagSpiderDead = true;
}
break;
case 2:
damage = iceBolt();
spiderHealth -= damage;
/* control spider is alive if it's dead set the flag to true */
if (spiderHealth <= 0) {
flagSpiderDead = true;
}
break;
} }
logPlayerAttack.push(damage);
if (flagSpiderDead == true) {
alert('You defeted the Spider! Congrats');
break;
} else {
alert('You did ' + damage + ' Damage! Spider has ' + spiderHealth + ' Health remaining');
}
damage = spiderAttack();
logSpiderAttack.push(damage);
if (playerHealth == false) {
alert('You have been killed');
} else {
playerHealth -= damage;
alert('Spider did ' + damage + ' You have ' + playerHealth + ' Health left');
} while (flagPlayerDead != true);
```