Skip to content
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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Card feature #12

wants to merge 4 commits into from

Conversation

kunal2812
Copy link

Fixes #8

index.html Outdated Show resolved Hide resolved
index.js Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
Copy link
Contributor

@dev-lovedeep dev-lovedeep left a 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(){
Copy link
Contributor

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){
Copy link
Contributor

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();
Copy link
Contributor

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

@dev-lovedeep
Copy link
Contributor

@kunal2812 are you working on this issue?

@kunal2812
Copy link
Author

@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.

@kunal2812 kunal2812 closed this by deleting the head repository Oct 14, 2022
@dev-lovedeep dev-lovedeep reopened this Oct 31, 2022
Copy link
Contributor

@dev-lovedeep dev-lovedeep left a 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

initiallly show cards and then hide
2 participants