function moveOutcomes() {

        //checking for collisions
        if (
            (currentSnake[0] + width >= (width * width) && direction === width) || //if snake hits bottom
            (currentSnake[0] % width === width - 1 && direction === 1) || //if snake hits right wall
            (currentSnake[0] % width === 0 && direction === -1) || //if snake hits left wall
            (currentSnake[0] - width < 0 && direction === -width) ||  //if snake hits the top
            squares[currentSnake[0] + direction].classList.contains('snake') //if snake goes into itself
        ) {
            alert("Game Over!")
            return clearInterval(interval)
        }

        const tail = currentSnake.pop()
        squares[tail].classList.remove('snake')
        currentSnake.unshift(currentSnake[0] + direction)
        //deals with snake getting apple
        if (squares[currentSnake[0]].classList.contains('apple')) {
            squares[currentSnake[0]].classList.remove('apple')
            squares[tail].classList.add('snake')
            currentSnake.push(tail)
            randomApple()
            score++
            scoreDisplay.textContent = score
            clearInterval(interval)
            intervalTime = intervalTime * speed
            interval = setInterval(moveOutcomes, intervalTime)
        }
        squares[currentSnake[0]].classList.add('snake')
    }
//function that deals with ALL the ove outcomes of the Snake
function that deals with ALL the ove outcomes of the Snake
function that deals with ALL the ove outcomes of the Snake
function moveOutcomes() {
        if (
            (currentSnake[0] + width >= (width * width) && direction === width) || 
            (currentSnake[0] % width === width - 1 && direction === 1) || 
            (currentSnake[0] % width === 0 && direction === -1) || 
            (currentSnake[0] - width < 0 && direction === -width) ||  
            squares[currentSnake[0] + direction].classList.contains('snake') 
        ) {
            alert("Game Over!")
            return clearInterval(interval)
        }
        const tail = currentSnake.pop()
        squares[tail].classList.remove('snake')
        currentSnake.unshift(currentSnake[0] + direction)
        if (squares[currentSnake[0]].classList.contains('apple')) {
            squares[currentSnake[0]].classList.remove('apple')
            squares[tail].classList.add('snake')
            currentSnake.push(tail)
            randomApple()
            score++
            scoreDisplay.textContent = score
            clearInterval(interval)
            intervalTime = intervalTime * speed
            interval = setInterval(moveOutcomes, intervalTime)
        }
        squares[currentSnake[0]].classList.add('snake')
    }
function moveOutcomes ( ) { if ( ( currentSnake [ 0 ] + width >= ( width * width ) && direction === width ) || ( currentSnake [ 0 ] % width === width - 1 && direction === 1 ) || ( currentSnake [ 0 ] % width === 0 && direction === - 1 ) || ( currentSnake [ 0 ] - width < 0 && direction === - width ) || squares [ currentSnake [ 0 ] + direction ] . classList . contains ( 'snake' ) ) { alert ( "Game Over!" ) return clearInterval ( interval ) } const tail = currentSnake . pop ( ) squares [ tail ] . classList . remove ( 'snake' ) currentSnake . unshift ( currentSnake [ 0 ] + direction ) if ( squares [ currentSnake [ 0 ] ] . classList . contains ( 'apple' ) ) { squares [ currentSnake [ 0 ] ] . classList . remove ( 'apple' ) squares [ tail ] . classList . add ( 'snake' ) currentSnake . push ( tail ) randomApple ( ) score ++ scoreDisplay . textContent = score clearInterval ( interval ) intervalTime = intervalTime * speed interval = setInterval ( moveOutcomes , intervalTime ) } squares [ currentSnake [ 0 ] ] . classList . add ( 'snake' ) }
function that deals with ALL the ove outcomes of the Snake
function that deals with ALL the ove outcomes of the Snake
//checking for collisions //if snake hits bottom //if snake hits right wall //if snake hits left wall //if snake hits the top //if snake goes into itself //deals with snake getting apple