Trying to find a way to display a console.log when a div is clicked. I am trying do do a simple game, if you click on the right box, you will get a message that you won.
as of now I am struggling with the bottom of my code, this part in particular:
function winningBox(){
 if (boxes.hasClass){
  console.log('you win');
 } else {
  console.log('you lose');
 }
}
winningBox();How do I get this to work? if box clicked has class of 'winning' the message should console.log winning. Please take a look. By the way I need to complete this on Vanilla JavaScript
//cup game
//add three cups to screen
//select li element
var button;
var boxes = document.getElementsByTagName('li');
var array = [];
console.log('working');
document.addEventListener('DOMContentLoaded', init);
function init() {
  document.addEventListener('click', winningBox);
  //shuffle li elements, and ad an id
  function test(boxes) {
    var randomBox = boxes[Math.floor(Math.random() * boxes.length)];
    array.push(randomBox);
    console.log('randombox:', randomBox);
    randomBox.classList.add('winning');
  }
  console.log(test(boxes));
  //user can click on a cup to see if correct
  function winningBox() {
    if (boxes.hasClass) {
      console.log('you win');
    } else {
      console.log('you lose');
    }
  }
  winningBox();
  //if cup is incorrect, display message
  //if correct, display won message
  //button to restart game
}body {
  background-color: #bdc3c7;
}
.main {
  background-color: #2c3e50;
  width: 300px;
  height: 100px;
}
li {
  background-color: gray;
  width: 80px;
  height: 80px;
  margin: 10px;
  list-style-type: none;
  display: inline-block;
  position: relative;
}<body>
  <container class="main">
    <ul>
      <li>1</li>
      <li>2</li>
      <li>3</li>
    </ul>
  </container>
  <script src="main.js"></script>
</body> 
     
     
     
    