solution

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Document</title>

</head>

<body>

    <pre>

        const stores = new Set();

// code from https://gist.github.com/mindplay-dk/1843c267fc633688059dfa5e3b07d0dd

internalRoots.forEach((root) => {

    let seen = new Map();

    function search(obj) {

        if (seen.has(obj)) {

            return;

        }


        seen.set(obj, true);

        for (name in obj) {

            if (name === 'getState') {

                stores.add(obj);

            }


            if ((obj?.hasOwnProperty?.(name)) && (typeof obj[name] === "object") && (obj[name] != null)) {

                search(obj[name]);

            }

        }

    }


    search(root);

});

    </pre>

    <hr>

    <pre>

        const result = {

            exam: examDetails[0].exam,

            title: examDetails[0].title,

            questions: questions.length,

            firstname: userDetails.firstname,

            lastname: userDetails.lastname,

            score: score,

            examno: userDetails.examno,

            seatno: userDetails.seatno,

            examiner: "",

            course: examDetails[0].course,

            attempted: answers.length,

          };

    </pre>

    <hr>

    <pre>

        await axios.post(`${baseApiUrl}/result.php`, result)

    </pre>

</body>

</html>