goods=[].map.call(document.querySelectorAll(".goods"), function(x){return x})
prices=goods.map(function(x){return +x.getAttribute("price")})
count=function(arr1, arr2){
var arr=[]
for(var i=0; i<arr1.length; i++) arr.push(arr1[i]*arr2[i])
return arr.reduce(function(x, y){return x + y})
}
inputs=goods.map(function(x){return x.querySelector("input")})
outs=goods.map(function(x){return x.querySelector(".out")})
inputs.forEach(function(x, i, arr){
x.onkeyup=function(){
outs[i].innerHTML=+this.value*prices[i]
var numbers = arr.map(function(x){return +x.value});
out.innerHTML=count(numbers, prices);
};
})
b.onclick=function(){
var numbers=inputs.map(function(x){return +x.value})
out.innerHTML=count(numbers, prices)
}