Skip to content

ToCode Solution: תרגיל סיכום - משחק תפוס תאדום#3

Open
shlomitha wants to merge 6 commits intoynonp:masterfrom
shlomitha:19-catch-red-lab
Open

ToCode Solution: תרגיל סיכום - משחק תפוס תאדום#3
shlomitha wants to merge 6 commits intoynonp:masterfrom
shlomitha:19-catch-red-lab

Conversation

@shlomitha
Copy link
Copy Markdown

No description provided.

}
scoreTxt.innerText='Score: '+ score;
redSquare.classList.remove("winner");
redIndex=randIndex(0, 4, redIndex);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you already have allEl, better to use allEl.length instead of a hardcoded 4

Copy link
Copy Markdown
Owner

@ynonp ynonp Nov 8, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic work and on time 👍
One bonus task (if you have time/will) is to add a timer, so if a user doesn't click within 2 seconds she loses points. You can use setTimeout for the timer

Take some time to review comments I left on previous exercises and move on to lesson 20. I'll send a detailed weekly plan by mail.


function chatchTheRed(ev){
var scoreToAdd=0;
if(!ev.target.nodeName=="DIV")
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redSquare=document.querySelector('.winner');
redSquare.classList.remove("winner");
redIndex=randIndex(0, allEl.length, redIndex);
allEl[Number(redIndex)].classList.add("winner");
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for Number(...) in array index. It happens automatically so this is just as good:

allEl[redIndex].classList.add('winner')

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants