Coder Social home page Coder Social logo

mentalmathsgame's Introduction

Mental maths game

Time based mental maths game- numbers are between 10 and 20

mentalmathsgame's People

Contributors

gbaja avatar

Stargazers

Peter Rhodes avatar

Watchers

James Cloos avatar  avatar

mentalmathsgame's Issues

Code review

Hey Fatimat, here is my code review. Don't feel like you need to make these changes but hopefully some of my comments are useful for your future projects.

  • There are lots of ids that could be classes. I think it's generally accepted to always use classes unless you have to use ids. As I understand it, ids have a greater 'specificity' than classes so if you are using the ids for Javascript and CSS sometimes it can get tricky when styling things as the id will always have precedence over other classes. I didn't properly understand specificity until quite late, this page is helpful for this: https://developer.mozilla.org/en/docs/Web/CSS/Specificity. This thread is good too, which suggests that you shouldn't use ids for css styling (unless you must): https://stackoverflow.com/questions/8279132/why-shouldnt-i-use-id-selectors-in-css.

  • In some places you have used tags without classes e.g. <h1>Mental Maths Quiz</h1> although the different h tags will display the fonts at different sizes it's best practice to add your own styling to them. I believe that different browsers sometimes display them differently so it's best to override the default with your own styles.

  • on line 25 you have onclick='window.location.reload()' - It's best practice not to have inline JS functions in your html. Instead you could have something like this in your JS file:

var playAgainButton = document.getElementsByClassName("playAgain");
playAgainButton.addEventListener('click', refreshPage);

function refreshPage(){
    window.location.reload();
};
  • Global variables. At the top of your file you have lots of variables, which is fine, but at the moment they are global variables. These can be dangerous if the project was bigger and you had lots of JS files. If two people accidentally called a global variable the same thing then your site might start behaving weirdly. This is not super important at this stage but it's something to be aware of (it will come up at Founders and Coders). The most common way to stop variables from being global is to wrap all the JS in an IIFE (Immediately Invoked Function Expression), which looks like this:
(function () {
    // logic here
})();

When the JS file is run the IIFE is invoked straight away so it doesn't affect the logic, however all the variables inside are scoped to the function instead of the window/document (so they are not global).

  • add a title to the at the top of the html doc. That way it will appear on the tab in your browser!
    screen shot 2017-09-03 at 18 13 49

  • Its a matter of choice but it's generally accepted to put a space between the css attribute and curly bracket so .name { rather than .name{.

  • When the value is 0 in CSS you don't need the px. So bottom: 0; instead of bottom: 0px; This doesn't make much difference but it makes less code and a bit cleaner.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.