I am trying to do a scavenger hunt with my students. Basically they do something, input an answer, if it is correct then the page should give them the URL to jump to the next clue. If it is wrong, they get a "Sorry, wrong" message and can keep inputting until they get it. I have read several sites and tried different things. I had the input worked out, but could not figure out how to display a hotlink for them to click on in JS. I have a free site setup and want to insert this Javascript but of course it is not working!
function myFunction() {
var letter = document.getElementById("personsInput").value;
var text;
let linkName = "Next challenge.";
// If the word is correct “chocolate"
if (letter === "chocolate") {
text = "<a ref ='https:// this is where the URL goes'> +linkName + " < /a>";
// If the word is anything else
} else {
text = "Sorry, wrong answer";
}
document.getElementById("demo").innerHTML = text;
}
<input id="personsInput" type="text">
<button onclick="myFunction()">What is your answer?</button>
<p id="demo"></p>