-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Card feature #12
base: main
Are you sure you want to change the base?
Card feature #12
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make these changes then i will merge your PR
timer.innerHTML = "<b>" + counter + "</b>"; | ||
else{ // Counter for timing the game | ||
counter++; // This counter is set to motion only when the game starts i.e when memoryCounter expires | ||
timer.innerHTML = "<b>" + counter + "</b>"; // Changes inner HTML | ||
} | ||
}, 1000); | ||
|
||
|
||
// To view all cards | ||
function viewAllCards(){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
showAllCards
would be a better name
} | ||
}, 1000); | ||
|
||
|
||
// To view all cards | ||
function viewAllCards(){ | ||
// Cards are made viewable when memoryCounter is greater than 0 | ||
if(memoryCounter>0){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this check should not be inside the function. To make a function reusable, it should do what its name suggests. Checks should be placed where the function is called.
for ex: if we add a hint button which show the all cards , then we can reuse this function, but if this check is there we cannot reuse it
|
||
// For timing the counters | ||
const interval = setInterval(function(){ | ||
if(memoryCounter>0){ // Makes a check on memoryCounter and stops after 5 secs | ||
memoryCounter--; | ||
viewAllCards(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this viewAllCards
function is called every time until the memory counter is zero, which is not good for performance. Add some conditions so that it do not run unnecessarily
@kunal2812 are you working on this issue? |
Sorry sir I was out for a while and didn't have access to my pc co could not make the required changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to work on your variable naming , otherwise code was ok
Fixes #8