There are no syntax errors but the code still dosent work!(javascript)
Im making a Genetitc Algorithm (to learn more about genetic algorithms click here )and im trying to determine the fitness value but when i do they all come out as 5 and im stumped as to why so pls can someone help my code is here: https://replit.com/@JULIODIAZ1/Genetic-Algorithm
Voters
DynamicSquid (4624)
On line 32:
if(gene1 = fitness_letters[0]){
It's supposed to be the comparison operator, not the assignment operator
The
=
in the if statements are messing it up=
is used for assignment,==
/===
is used for comparisonRight now, you are setting the value of
gene1
toH
and it returnsH
(meaning true in JavaScript)fix:
this occurs 5 times (one for each gene) and everytime it += 1, which is where the 5 comes from