http://unkk9a8915e1.neonz27.koding.io/genetics的Javascript添加整数作为一个字符串
例如,如果你加6和4的1-2范围内你会得到641或642,而不是11或12!
function calculate()
{
var radius1 = document.getElementById("cell1Value").value;
var radius2 = document.getElementById("cell2Value").value;
var radiusAvrg = (radius1 + radius2)/2;
var childRadius = radius1 + radius2 + (Math.floor(Math.random() * 6) + 1);
console.log(childRadius);
confirm("The child's radius is " + childRadius);
}
<h1>ParentCell01's Radius</h1>
<input type="text" name="cell1Value" id="cell1Value" />
<br />
<h1>ParentCell02's Radius</h1>
<input type="text" name="cell2Value" id="cell2Value"/>
<br />
<button onclick="calculate()">Calculate child's radius.</button>
你忘了提问了。 – nnnnnn