I suggest to check each container (not an array as in previous answer):
function checkawinner(box) {
box.addEventListener("click", function(){
if (box.classList.contains('winning')) {
console.log('you win');
} else {
console.log('you lose');
}
}, false);
}
for (index = 0; index < boxes.length; ++index) {
checkawinner(boxes[index]);
}
A pen with "alerts": http://codepen.io/VsevolodTS/pen/BKBjpP