Https://www.codecademy.com/practice/projects/mysterious-organism

https://www.codecademy.com/practice/projects/mysterious-organism

I am currently having an issue understanding how the solution was solved this way. I looked at the solution for this code and I need someone to explain why they chose certain parameters.
Here is the following code:
compareDNA(otherOrg) {
const similarities = this.dna.reduce((acc, curr, idx, arr) => {
if (arr[idx] === otherOrg.dna[idx]) {
return acc + 1;
} else {
return acc;
}
}, 0);

1 Like