JSFiddle - React, Tailwind, and code Playground
JavaScript
let min = 1;
let max = 6;
let wuerfel_anzahl = 1;
let wuerfel_counter = [];
let test = [1];
const wuerfel = function(wuerfel) {
for (let i = 0; i < wuerfel; ++i) {
let rnd_number = Math.floor(Math.random() * (max - min + 1) + min);
wuerfel_counter.push(rnd_number);
}
};
const ausgabe = function() {
x = wuerfel_counter.length;
y = wuerfel_counter[x - 1];
wuerfel_counter.pop();
if (x > 1) {
console.log(`Die Würfel sind gefallen! Es sind die Zahlen ${wuerfel_counter.join(" ")} und ${y}`);
} else {
console.log(`Die Würfel sind gefallen! Es ist die Zahl ${y}`);
}
};
wuerfel(wuerfel_anzahl);
ausgabe();
console.log(test.pop());