JSFiddle - React, Tailwind, and code Playground

HTML

<html>
<body>
<h2>Riddel</h2>
<p>There are 3 Gods, one on the Left, one in the Middle and one on the Right. One of the Gods it "Ture" which always says the truth, one is "False", which always lies and one is "Random", which randomly answers. You can ask 3 times a Yes or No question, each time asking just one of the Gods.</p>
<h2>Solution</h2>
</body>
</html>

JavaScript

const log = (text) => {
  const newDiv = document.createElement("p");
  newDiv.appendChild(document.createTextNode(text));
  document.body.appendChild(newDiv); 
};

const position = ["Left", "Middle", "Right"];

const test = (doLogs) => {
  // random order of gods:
  const gods = [
    {name: "True", answer: (v) => v}, 
    {name: "False", answer: (v) => !v}, 
    {name: "Random", answer: (v) => Math.random() > 0.5}
  ].sort( () => Math.random() > 0.5 ? 1 : 0 );

  doLogs && log(`Q1: ask the left god: "If I would ask you if the middle is Random, would you say yes?"`);
  const Q1 = gods[0].answer(gods[0].answer(gods[1].name === "Random")) ? 2 : 1;
  doLogs && log(`- Based on Q1 the god that isn't Random is: ${position[Q1]}`);


  doLogs && log(`Q2: ask the ${position[Q1]} god (which isn't Random) if something is true`);
  const Q2 = gods[Q1].answer(true);
  doLogs && log(`- Answer to Q2 is: ${Q2}`);


  doLogs && log(`Q2: ask the ${position[Q1]} god (which isn't Random) again, this time if the Left is Random`);
  const Q3 = gods[Q1].answer(gods[0].name === "Random");
  doLogs && log(`- Answer to Q3 is: ${Q3}`);

  // Return results
  const solution = ["A", "B", "C"];
  solution[Q1] = Q2 ? "True" : "False";
  doLogs && log(`${position[Q1]} is ${solution[Q1]}, because Q2 is ${Q2}`); 

  solution[0] = (Q3 && Q2) || (!Q3 && !Q2) ? "Random" : (!Q2 ? "True" : "False");
  doLogs && log(`${position[0]} is ${solution[0]}`);

  const reverseQ1 = Q1 === 1 ? 2 : 1;
  solution[reverseQ1] = (Q3 && Q2) || (!Q3 && !Q2) ? (!Q2 ? "True" : "False") : "Random";
  doLogs && log(`${position[reverseQ1]} is ${solution[reverseQ1]}`);

  doLogs && log(`Order found out: ${solution.join(", ")}`);
  const correctOrder = gods.map(g => g.name);
  doLogs && log(`check with correct order: ${correctOrder.join(", ")}`);
  
  return solution[0] === correctOrder[0] 
     &&  solution[1] === correctOrder[1] 
     &&  solution[2] === correctOrder[2];
}

test(true);

const runCount = 100_000;
log(`Do...