Public
Back

Version 6

10/24/2024
/** @jsxImportSource https://esm.sh/react */
import React, { useState, useEffect } from "https://esm.sh/react";
import { createRoot } from "https://esm.sh/react-dom/client";

function slugify(text: string): string {
return text
.toLowerCase()
.trim()
.replace(/[^\w\s-]/g, '')
.replace(/[\s_-]+/g, '-')
.replace(/^-+|-+$/g, '');
}

function shuffleArray<T>(array: T[]): T[] {
const newArray = [...array];
for (let i = newArray.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[newArray[i], newArray[j]] = [newArray[j], newArray[i]];
}
return newArray;
}

function CreateGame() {
const [name, setName] = useState("");
const [terms, setTerms] = useState("");
const termCount = terms.split("\n").filter(t => t.trim()).length;

const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
const termsList = terms.split("\n").filter(t => t.trim());
if (termsList.length < 24) {
alert("Please enter at least 24 terms (one per line)");
return;
}
if (!name.trim()) {
nn-bingo.web.val.run
Updated: October 24, 2024