{"size": 1467, "ext": "js", "max_stars_repo_path": "script.js", "max_stars_repo_name": "akkshaychauhan/Memory-Card-", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "script.js", "max_issues_repo_name": "akkshaychauhan/Memory-Card-", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "script.js", "max_forks_repo_name": "akkshaychauhan/Memory-Card-", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 23.2857142857, "max_line_length": 65, "alphanum_fraction": 0.5978186776}
 const cards = document.querySelectorAll('.memory-card');

  let hasFlippedCard = false;
  let lockBoard = false;
  let firstCard, secondCard;

 function flipCard() {
 	if(lockBoard) return;
    if(this === firstCard) return;

  this.classList.toggle('flip');

  if(!hasFlippedCard) {
  	//first click
  	hasFlippedCard = true; 
  	firstCard = this;
    
    return; 
  }
  	// second click
  	    secondCard = this;
  	    console.log({firstCard, secondCard});

  	   checkForMatch();

 }
 function checkForMatch() {
 	 //do card match?
        if(firstCard.dataset.framework === 
        	secondCard.dataset.framework){
        disableCard();
        } else {
              unflipCard();
        }
 }
 function disableCard() {
        //it's a match
        firstCard.removeEventListener('click', flipCard);
        secondCard.removeEventListener('click', flipCard);

        resetBoard();
 }
 function unflipCard() {
 	  lockBoard = true;
        	//not a match
        	setTimeout( () => {
        	firstCard.classList.remove('flip');
        	secondCard.classList.remove('flip');

        	resetBoard();
        }, 1500);
 }
 function resetBoard() {
 	[hasFlippedCard, lockBoard] = [false, false];
 	[firstCard, lockBoard] = [null, null]; 
 }
 (function shuffel() {
 	 cards.forEach( card => {
 	 	let randomPos = Math.floor(Math.random() * 12);
 	 	card.style.order = randomPos;
 	 });
 	 	})();
 cards.forEach(card => card.addEventListener('click', flipCard));