Project 1#23
Conversation
|
|
||
|
|
||
| function shuffleArray(arr) { | ||
| for (var i = arr.length - 1; i > 0; i--){ |
There was a problem hiding this comment.
Explain this line of codes to me, why does the loop reversing? and how does the es6 code works?
Use simple example.
| @@ -0,0 +1,291 @@ | |||
| //Part 1 - Shuffle array, add a random number btw 1-4 into array(for adding rounds) | |||
| var instructorMoves = [37,38,39,40] | |||
There was a problem hiding this comment.
Avoid creating a global variables, you can put this under line 21.
| return (value - 36); | ||
| }) | ||
|
|
||
| for(let e = 0; e <= randSequence.length; e++){ |
There was a problem hiding this comment.
hmm? why not just tagged your instructor number class into one div, so you don't have to do this loop instead.
e.g.
var danceMove = instructorMoves [Math.floor( Math.random() * instructorMoves.length )]
$('.instructor').addClass(`dance${danceMove}`)| this.play(); | ||
| }, false); | ||
|
|
||
| $button.on('click' , function () { |
There was a problem hiding this comment.
what button is this? Be more descriptive on your variable naming.
| $(".startBtn").hide() | ||
| $(".resetBtn").show() | ||
|
|
||
| $body.on('keydown', (e) => { |
| // Set keys with different images for player 1 | ||
| if(strOfKeys === 37) { | ||
| $('.playerOneDiv').addClass("move"); | ||
| $('.playerOneDiv').css('backgroundImage', `url("./assets/images/player1_1.png")`); |
There was a problem hiding this comment.
again same issues here like the instructor moves, why just add in the class instead?
|
Project Workflow: 2 / 5 Glow
Grow
Things to look out for
|
|
Project Workflow: 3 / 5 GlowInteresting and fun game. :) GrowKeep DRY(Don't Repeat Yourself) and KISS(Keep It Simple Stupid) principle in your mind, save your lines and make the logic clear if possible. Indentation is very important for readability and debugging. Avoid using of global scope. Things to look out forCode refactoring with DRY principle. |
| whichPlayer = 2 | ||
| } | ||
|
|
||
| //Part 3 - Matching keypressed with instructorMoves in sequence |
There was a problem hiding this comment.
You may refactor matching logics for reducing repetition.
No description provided.