Detect if player is left or right of enemy

So basically I’m making this game (sort of like super smash bros I guess but 8bit) and I need some basic enemy AI.
How can I make a script that detects if the player is to the left or right of the enemy, so I can make the enemy move towards the player?

Simply compare x coordinates of enemy and player:

        if(enemy.transform.position.x > player.transform.position.x){
               //Move left
        } else {
               //Move right
        }