var x = 0;
var o = 0;
var num = []
I have an object and within the object an array:
var win = {
winset: [012,345,678,036,147,258],
checkwinSet: function(num) {
this.winset.forEach(set => {
if (set === num) {
alert('great')
}
})
}
}
And then a for loop (for loop is inside an addeventlistener function):
var c = e.target.parentElement.children
for (i = 0; i < c.length; i++) {
c[i].setAttribute('data-move', 'o')
if (x > 2) {
if ((c[i].innerHTML != '') & (c[i].innerHTML === 'x')) {
num += Number(c[i].getAttribute('data-position'))
console.log(num)
if (i > 2) {
win.checkwinSet(num)
break;
}
}
}
}
But anytime I console.log(win.winset) I get 10 as the first result in the array instead of 012 and 30 instead of 036.
Please what I'm I doing wrong and why is that??
Also my num array doesn't return numbers rather returns as string