考虑这段代码。我将字符串加载到数组中的位置。然后发送字符串以查看它是否发生变化,是否发生变化,添加它。但由于我使用一个简单的数组来执行此操作,因此我无法向数组元素添加属性。
....
var generationOffspring = [];
var offspringScore = 0;
// "load" the offspring into an array, check each offspring if it mutates and then score it.
for(var i = 0; i < amount_offspring; i++)
{
// "load" text into array
generationOffspring[i] = start_text;
// send the string to see if it evolves
generationOffspring[i] = evolve(generationOffspring[i], target_text);
// then score the string
offspringScore = score(target_text, generationOffspring[i]);
....
那么如何让offspringScore
与generationOffspring[i]
相关联?