I'm currently building my first javascript game, Hangman. The application is working but if the alphabetical guess is correct it just prints the letter in the guessed order and not in the order of the word itself.
The right guesses ends up in the "rightInputDisplay" Array which i then display as text. Can i maybe somehow print the word based on the correct words index? Any tips or advice?
const gissaOrd = function () {
gissaInput = document.getElementById("gissa").value;
console.log(gissaInput);
// Right guess
//Ordarray är ofiltrerad input
//Gissainput är det man gissat
if (ordArray.includes(gissaInput)) {
console.log("du har en rätt boktstav");
rättArray.push(gissaInput);
rightInputDisplay = rightInputDisplay + gissaInput;
// För att få rätt siffra på rätt plats; For-loop över ordArray. Eller kanske rentav köra en for
// Loop med ovanstående condition.
document.getElementById("rättbokstav").innerHTML = `${rightInputDisplay}`;
checkWin();
}