Recommiting the memory game exercise of javascript with more modular approach