Created
March 7, 2021 19:10
-
-
Save Albertbol/0ead1fe9d3caa60a071249daf80cb9dc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
crossover(a, b) { | |
const midpoint = Math.floor(Math.random() * (phraseToGuess.length - 2)) + 1 | |
let crossed = '' | |
for (let i = 0; i < phraseToGuess.length; i++) { | |
if (i <= midpoint) { | |
crossed += a[i] | |
} else { | |
crossed += b[i] | |
} | |
} | |
return crossed | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment