import React, { useState } from "react"; import { Title } from "./title.js"; import { ProgressIndicator } from "./progressIndicator.js"; import { DisplayElementForComparison } from "./displayElementForComparison.js"; import { ComparisonActuator } from "./comparisonActuator.js"; export function Homepage({ listOfElementsInit }) { /* Statefull elements */ const [listOfElements, setListOfElements] = useState(listOfElementsInit); const numStepsInit = 0; const [numStepsNow, setNumStepsNow] = useState(numStepsInit); const increaseNumSteps = (n) => setNumStepsNow(n + 1); const isListOrdered = false; const pairCurrentlyBeingComparedInit = [ listOfElementsInit[0], listOfElementsInit[1], ]; const [pairCurrentlyBeingCompared, setPairCurrentlyBeingCompared] = useState( pairCurrentlyBeingComparedInit ); const changePairCurrentlyBeingCompared = (element1, element2) => setPairCurrentlyBeingCompared([element1, element2]); const chooseNextPairToCompareRandomly = ({ listOfElements }) => { let l = listOfElements.length; let n1 = Math.floor(Math.random() * l - 0.001) % l; let n2 = (n1 + 1 + Math.floor(Math.random() * l)) % l; changePairCurrentlyBeingCompared(listOfElements[n1], listOfElements[n2]); }; return (