mirror of
https://github.com/FranP-code/Hangman-game-with-React.git
synced 2025-10-13 00:42:32 +00:00
17 lines
302 B
JavaScript
17 lines
302 B
JavaScript
const SelectRandomWord = (arrayWords) => {
|
|
|
|
const randomWord = Math.trunc(
|
|
|
|
Math.random() * (arrayWords.length - 0) + 0
|
|
)
|
|
|
|
if (arrayWords[randomWord] === undefined) {
|
|
|
|
return SelectRandomWord()
|
|
}
|
|
|
|
return arrayWords[randomWord]
|
|
}
|
|
|
|
export default SelectRandomWord
|