Dimaz,
...всё проще ...
var formula = [10,6.7,3.4];
var user1 = [1,0,1,1,1,0,0,2,2,2];
var user2 = [2,1,2,0,1,2,2,2,0,0];
var result = 0;
calculate();
function calculate(){
for(var i=0; i<user1.length; i++){
result +=formula[Math.abs(user1[i]-user2[i])]
}}
alert(result);
|