How to put number in the appropriate cell?

Hello. Make the task in which you want each number from the array output in sootvetstvuyuschuyu cell in the table. Total cells 9, and numbers much more. For example, in the array there are numbers 2,1,4,3,6,8. What numbers can be repeated. See 2-ku - put in cell number 2.. 1-MC in cell 1, and so on.
I have an array of variables 1 to 9
var massiv = [];
var fkol_1 = 0;
var fkol_2 = 0;
var fkol_9 = 0;

These variables are needed in order to check the number from the array and display them in a table cell(td). For example, like this:
if ((massiv[i] == 1)) {fkol_1++;}
if ((massiv[i] == 2)) {fkol_2++;}
//and so on up to 9

There are 2 variables a=42, b=79. Their meaning can be different, but they double digit. And I need to separate them so that they become unique(4,2,7,9). Then the values of these variables enter into the array massiv[] using the function:
function splitNumber(number) {
 number.toString().split(").forEach(number => massiv.push('('+number+')'));

Now the essence of the question: how can I verify the last 4 digits in the array (in our example, these four digits are variables and a,b(4,2,7,9) ) and record them in a certain cell in the table in brackets? For example, in our cell there are already 2 here, and since the last 4 numbers of array 2 is found on, then put it in brackets (2) to obtain 2(2) ? So I deduce variables:
/* and so on to fkol_9' */

For clarity, a living example -
July 9th 19 at 13:09
1 answer
July 9th 19 at 13:11
Sorry, but it's unreadable.

if ((massiv[i] == 1)) {fkol_1++;}
if ((massiv[i] == 2)) {fkol_2++;}
//and so on up to 9

replace at least

and so on, no need to write 10 lines in operation that with the right approach it is possible to write a single line.

And naming variables, try to name them clearly and in English
if ((massiv[i] == i )) { fkol[massiv[i]]++ }
If you go by the "living example", you'll see that I vovtroy table with variables fkol_1, etc. As in this case, I return the value? - nikita.Stracke commented on July 9th 19 at 13:14
if ((massiv[i] == i )) { fkol[massiv[i]]++ } does not work... - nikita.Stracke commented on July 9th 19 at 13:17
If excess to just leave a body, the IFA, and the meaning will not change.

fkol_1 replaced by fkol[1] and so on. - antonetta.Collins commented on July 9th 19 at 13:20
a : incorrect because it probably is not declared: var fkol = []; - antonetta.Collins commented on July 9th 19 at 13:23
: announced. Left body, and I fkol[1] = appears in the 1st cell of the NaN.. You watched a live example? - nikita.Stracke commented on July 9th 19 at 13:26
: - here I have updated - nikita.Stracke commented on July 9th 19 at 13:29
the array needs to be initialized or use trinary or operator to check for the existence of the element.
In General, if I understand correctly your question, here's a bit updated fiddle
in General your code style is saved, so questions should arise.

But in General: take more time to study the culture code and implementation logic of your programs - antonetta.Collins commented on July 9th 19 at 13:32
: thanks a lot. Last question:
Here is your updated fiddle - I changed the condition in if. There you have 9, but I put 16 as the original condition counts the number of repeated numbers and displayed in a table. If you take the online example displays the same output as yours, but corrected by me.
Now regarding the issue: in my example (slightly modified) in the fourth cell add up the numbers between itself and displays their sum: let's Say, 11111 2 3 will be equal to 10, as 1+1+1+1+1+2+3. Therefore, the top 10 recorded in the fourth cell. And so for each row(TR). You have a 4 cell(td) in your example ( oddly finds and displays 0. How to make the numbers NOT in parentheses were considered only among themselves, and the numbers in brackets are only among themselves.
At the end of a JavaScript is shown as is the sum of the 4th cell. Tell me - nikita.Stracke commented on July 9th 19 at 13:35
: I already wrote that code not readable) I can't understand where to appear.
I even generally don't understand where you add up some numbers with others.
The numbers in brackets 16,17,18,19 are stored in the array indices, the sum by rows we can calculate something like this:

var str1 = 0;
var str2 = 0;
var str3 = 0;

for (var i = 16; i < 20; i++) {
if (massiv[i] < 4) {
str1 += massiv[i];
} else if (massiv[i] < 7) {
str2 += massiv[i];
} else {
str3 += massiv[i];

so str1 will contain the sum of cells 1,2,3
in str2 will contain the sum of cells 4,5,6
in str3 is stored the sum of the cells 7,8,9 - antonetta.Collins commented on July 9th 19 at 13:38
just think of the amount not reduce, and right in your function, and quietly get what you want.

I think the question was answered in some detail, and I deserve a tick ;)
Otherwise, it is necessary to formulate a question, a La: "decide for me laboratory work" - antonetta.Collins commented on July 9th 19 at 13:41
thanks, you really helped) Put a tick. Will his method to do. Sent me - nikita.Stracke commented on July 9th 19 at 13:44

Find more questions by tags jQueryHTMLJavaScriptCSS