code-sketch / memory-game Goto Github PK
View Code? Open in Web Editor NEWMemory card game in VanillaJS
Memory card game in VanillaJS
At the start of the game not all the cards are displayed so there is a problem of usability, also the menu is not readable.
function resetBoard() {
[hasFlippedCard, lockBoard] = [false, false];
[firstCard, secondCard] = [null, null];
}
Easily replaces with
function resetBoard() {
hasFlippedCard = lockBoard = false;
firstCard = secondCard = null
}
Try to count how often vue turns out on top-left card
(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;
});
if (lockBoard) {return;}
if (this === firstCard) {return;}
I came across your memory sample project and I think this is really nice work. Ideally I would like to use your code for an educational project for new colleagues but given you have not put any license I don't want to do it. Did you intentionally not include a licence or did you simply forget to use it? @marina-ferreira
Estou seguindo o tutorial e tentando reproduzir o código, porém ao clicar na carta ocorre apenas o efeito de clique, sem o flip e a mudança de imagem. Não está aparecendo nenhuma mensagem de erro então não consigo identificar o que pode estar errado. Gostaria de ajuda caso alguém tenha encontrado o mesmo problema.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.