Skip to content

Instantly share code, notes, and snippets.

@cupofcodeblog
Last active January 28, 2024 19:03
Wordle in React part 2 - adding squares-string logic to Modal.js
export default function ProgressModal({ ..., squaresString, gameNo }) {
...
function shareResult() {
// to differentiate between winning on 6th try and losing
let turnIndex = isCorrect ? turn : 0;
let resultString = ""
for (let i = 0; i < turnIndex; i++){
let newRow = squaresString[i] + "\n";
resultString += newRow;
}
let prefix= `Wordlestruck ${gameNo} ${turnIndex===0?'X':turnIndex}/6\n\n`
resultString = prefix + resultString
...
<...copy to clipboard code...>
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment