Skip to content

Commit 062e1cf

Browse files
committed
Try break
1 parent cadd654 commit 062e1cf

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎assignments/prototypes.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,10 @@ const tezzeret = new Villain({
214214

215215
function turnSimulator(hero, villain) {
216216
console.log(`Game Start.`)
217+
let winner = null;
217218
for (let i = 99; i > 0; i--) {
218219
if (hero.hp <= 0 || villain.hp <= 0) {
219-
console.log(`Game is over.`);
220+
break;
220221
} else {
221222
if ((Math.floor(Math.random() * 100) + 1) % 2 === 0) {
222223
console.log(`It's ${hero.name}'s turn.`)
@@ -234,6 +235,7 @@ function turnSimulator(hero, villain) {
234235
}
235236
}
236237
}
238+
return `Game Over`
237239
}
238240

239241
console.log(turnSimulator(jace, tezzeret));

0 commit comments

Comments
 (0)