+1 vote
by
I have an array of HTML div that has the numbers I want. When I try to work with the array, the script only sees the html element, how do I get textContent out of the div?
5f864d2b483e5567860940.png


function itogC(form) {
//передаю div из формы в массив
const itog1 = [...form.querySelectorAll(`.c1, .c2, .c3, .c4, .c5, .c6`)];
const km = [1, 0.25, 0.5, 0.75, 1, 0.25];
console.log(itog1);

const res = itog1.reduce(
(a,v,i) =>{
if(!a[v]){
a[v] = 0;
}

a[v] = a[v] + km[i];
return a;
},
{}
);
console.log(res);
};
by
I don't get it, but the content of the element is in the property.innerHTML or.innerText

1 Answer

0 votes
by
 
Best answer
"The script only sees" what you have written into it.
(a,v,i) =>{}
v-is your div. You wrote the name of the desired property of this div in the question. What is the difficulty?
...