From 0e089ffb052099df9b8870dcb6c4d7651668bafa Mon Sep 17 00:00:00 2001 From: Axel O Date: Mon, 12 Dec 2022 17:23:23 +0100 Subject: [PATCH] Tous les modules --- modules/scoreboard.mjs | 49 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 modules/scoreboard.mjs diff --git a/modules/scoreboard.mjs b/modules/scoreboard.mjs new file mode 100644 index 0000000..09f7932 --- /dev/null +++ b/modules/scoreboard.mjs @@ -0,0 +1,49 @@ +export class Gamer { + constructor(Name, Score){ + this.name = Name; + this.score = Score; + } + +} + +export function Scoreboard() +{ + let alias = prompt("Entre ton nom", "User"); + let gamers = []; + gamers.push( new Gamer(alias, 0)); + console.log(gamers); + //let table = document.getElementById("scoreTable"); + + //console.log(table); + //console.log(tableau); + renderArray(gamers); + +} + +export function renderArray(gamers) +{ + let tableau= document.getElementById("scoreTable"); + console.log(tableau); + tableau.innerText = ""; + gamers.forEach((gamer, index) => { + let tableRow = document.createElement("tr"); + let nameTd = document.createElement("td"); + let scoreTd = document.createElement("td"); + //rmvTd = document.createElement("td"); + //rmvButton = document.createElement("button"); + //rmvButton.innerText = "delete"; + //rmvButton.setAttribute("array-index", index); + //rmvButton.addEventListener("click", removeStudent); + //rmvTd.appendChild(rmvButton); + + nameTd.innerText = gamer.name; + scoreTd.innerText = gamer.score; + + tableRow.appendChild(nameTd); + tableRow.appendChild(scoreTd); + //tableRow.appendChild(rmvTd); + tableau.appendChild(tableRow); + + }); + console.log(tableau); +} \ No newline at end of file