-
Notifications
You must be signed in to change notification settings - Fork 208
Open
Description
1. Destructive assignment in this simple case?
function resetBoard() {
[hasFlippedCard, lockBoard] = [false, false];
[firstCard, secondCard] = [null, null];
}Easily replaces with
function resetBoard() {
hasFlippedCard = lockBoard = false;
firstCard = secondCard = null
}2. Shuffle is incorrect
Code flow: shuffle is not uniform
Try to count how often vue turns out on top-left card
Code style
(function shuffle() {
cards.forEach(card => {
let ramdomPos = Math.floor(Math.random() * 12);
card.style.order = ramdomPos;
});
})();let should be replaced with const
12 should be replaced with cards.length
moreover why you use IIFE here? you could simply write
// shuffle elements
cards.forEach(card => {
const ramdomPos = Math.floor(Math.random() * cards.length);
card.style.order = ramdomPos;
});3. It is a de-facto standard to use brackets in if statements (even in one-liners)
if (lockBoard) {return;}
if (this === firstCard) {return;}And there are plenty more...
Edymov, HlebKrah, akkshaychauhan, thecoorum, robsoncloud and 2 more
Metadata
Metadata
Assignees
Labels
No labels