From 6e5d8cdf232bfc29324a93f51fd5099856c260c7 Mon Sep 17 00:00:00 2001 From: EhabElasam Date: Wed, 24 Apr 2024 20:45:16 +0200 Subject: [PATCH] e --- srcs/frontend/js/tournament.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/srcs/frontend/js/tournament.js b/srcs/frontend/js/tournament.js index 8b292c7..6f0755f 100644 --- a/srcs/frontend/js/tournament.js +++ b/srcs/frontend/js/tournament.js @@ -45,8 +45,9 @@ function startTournament(playerCount) { const players = []; for (let i = 1; i <= playerCount; i++) { let playerName = prompt(`Enter name for Player ${i}:`); - playerName = playerName.replace(/[^a-z0-9]/gi, '').substring(0, 7); - players.push(playerName || `Player ${i}`); + if (playerName) + playerName = playerName.replace(/[^a-z0-9]/gi, '').substring(0, 7); + players.push(playerName || `X ${i}`); } shuffleArray(players); showTournament(players, playerCount);