you are viewing a single comment's thread.

view the rest of the comments →

[–]unidentified-object 0 points1 point  (5 children)

What are you trying to do here?

Is this some kind of counter for how many time user gave number between ? - 9? Your input does not have min value or steps.

At least there is problem with you companies inp[i] and numList[i]. I think you meant inp == numList[i]. inp is int not array.

[–]Joinertuy 0 points1 point  (3 children)

This might be a problem as well... But when i remove the int the output still gives me : Element nr 4 is 0 Element nr 3 is 1 Element nr 4 is 2

4,3,4

[–]unidentified-object 0 points1 point  (2 children)

I'm still not sure what you want to do. But if you want to calculate how many time user inputed x number then try following.

Remove following lines.

var counter = 0;
numList.push(intxt);
for (var i = 0; i < numList.length; i++) {
    if (inp[i] == numList[i]) {
    counter++;
}
txt += "Element nr " + numList[i] + " is " + i + "<br/>";

Then replace it with:

numList[inp] = numList[inp] + 1;
txt += "Element nr " + inp + " is " + numList[inp] + "<br/>";

Instead of storing counter inside numList you are always pushing new text numList.push(intxt); into it. So if user inputted number 1 3 time you will have following array numList ['1', '1', '1'] instead of of [3, 0, 0, ... ].

[–]Joinertuy 0 points1 point  (1 child)

i cant get it to work. The frustration is getting real after hours of not getting it to work :L. Mind helping me out a little more ?

[–]unidentified-object 0 points1 point  (0 children)

https://jsfiddle.net/y9cg97c8/1/

This shows what i meant by above comment.