Skip to content

Instantly share code, notes, and snippets.

@Albertbol
Created March 7, 2021 19:10
Show Gist options
  • Save Albertbol/0ead1fe9d3caa60a071249daf80cb9dc to your computer and use it in GitHub Desktop.
Save Albertbol/0ead1fe9d3caa60a071249daf80cb9dc to your computer and use it in GitHub Desktop.
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