Finished logic of JavaScript -working on CSS