This Chat is read-only. Login to resume chatting.
<!DOCTYPE html>
<html lang="nl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Memory Game</title>
<style>
body {
font-family: 'Arial', sans-serif;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
background-color: #f0f8ff;
margin: 0;
height: 100vh;
}
.memory-game {
display: grid;
grid-template-columns: repeat(5, 100px);
grid-template-rows: repeat(2, 100px);
gap: 10px;
}
.card {
width: 100px;
height: 100px;
background-color: #ff69b4;
display: flex;
justify-content: center;
align-items: center;
font-size: 24px;
border-radius: 8px;
cursor: pointer;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}
.card.flipped {
background-color: #ffc0cb;
}
.card.matched {
background-color: #98fb98;
cursor: default;
pointer-events: none;
}
#reset-button {
margin-top: 20px;
padding: 10px 20px;
font-size: 16px;
background-color: #ff69b4;
color: white;
border: none;
border-radius: 8px;
cursor: pointer;
display: none;
}
</style>
</head>
<body>
<div class="memory-game" id="memory-game">
<div class='card'>2¹</div>
<div class='card'>2³</div>
<div class='card'>2</div>
<div class='card'>2²</div>
<div class='card'>8</div>
<div class='card'>2⁴</div>
<div class='card'>4</div>
<div class='card'>2⁵</div>
<div class='card'>16</div>
<div class='card'>32</div>
</div>
<button id="reset-button">Speel opnieuw</button>
<script>
const cards = document.querySelectorAll('.card');
let flippedCards = [];
let matchedPairs = 0;
function flipCard() {
if (flippedCards.length < 2 && !this.classList.contains('flipped')) {
this.classList.add('flipped');
flippedCards.push(this);
if (flippedCards.length === 2) {
setTimeout(checkForMatch, 1000);
}
}
}
function checkForMatch() {
const [card1, card2] = flippedCards;
const expression = card1.innerText;
const result = eval(expression.replace('²', '**2').replace('³', '**3').replace('⁴', '**4').replace('⁵', '**5'));
if (card2.innerText == result || card1.innerText == eval(card2.innerText.replace('²', '**2').replace('³', '**3').replace('⁴', '**4').replace('⁵', '**5'))) {
card1.classList.add('matched');
card2.classList.add('matched');
matchedPairs++;
if (matchedPairs === 5) {
document.getElementById('reset-button').style.display = 'block';
}
} else {
card1.classList.remove('flipped');
card2.classList.remove('flipped');
}
flippedCards = [];
}
function resetGame() {
cards.forEach(card => {
card.classList.remove('flipped', 'matched');
});
flippedCards = [];
matchedPairs = 0;
document.getElementById('reset-button').style.display = 'none';
}
cards.forEach(card => card.addEventListener('click', flipCard));
document.getElementById('reset-button').addEventListener('click', resetGame);
</script>
</body>
</html><!DOCTYPE html>
<html lang="nl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Memory Game</title>
<style>
body {
font-family: 'Arial', sans-serif;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
background-color: #f0f8ff;
margin: 0;
height: 100vh;
}
.memory-game {
display: grid;
grid-template-columns: repeat(5, 100px);
grid-template-rows: repeat(2, 100px);
gap: 10px;
}
.card {
width: 100px;
height: 100px;
background-color: #ff69b4;
display: flex;
justify-content: center;
align-items: center;
font-size: 24px;
border-radius: 8px;
cursor: pointer;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
position: relative;
}
.card.hidden::after {
content: '?';
position: absolute;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
background-color: #ffc0cb;
border-radius: 8px;
}
.card.flipped {
background-color: #ffc0cb;
}
.card.matched {
background-color: #98fb98;
cursor: default;
pointer-events: none;
}
#reset-button {
margin-top: 20px;
padding: 10px 20px;
font-size: 16px;
background-color: #ff69b4;
color: white;
border: none;
border-radius: 8px;
cursor: pointer;
display: none;
}
</style>
</head>
<body>
<div class="memory-game" id="memory-game">
<div class='card hidden'>2¹</div>
<div class='card hidden'>2³</div>
<div class='card hidden'>2</div>
<div class='card hidden'>2²</div>
<div class='card hidden'>8</div>
<div class='card hidden'>2⁴</div>
<div class='card hidden'>4</div>
<div class='card hidden'>2⁵</div>
<div class='card hidden'>16</div>
<div class='card hidden'>32</div>
</div>
<button id="reset-button">Speel opnieuw</button>
<script>
const cards = document.querySelectorAll('.card');
let flippedCards = [];
let matchedPairs = 0;
function flipCard() {
if (flippedCards.length < 2 && !this.classList.contains('flipped')) {
this.classList.remove('hidden');
this.classList.add('flipped');
flippedCards.push(this);
if (flippedCards.length === 2) {
setTimeout(checkForMatch, 1000);
}
}
}
function checkForMatch() {
const [card1, card2] = flippedCards;
const expression = card1.innerText;
const result = eval(expression.replace('²', '**2').replace('³', '**3').replace('⁴', '**4').replace('⁵', '**5'));
if (card2.innerText == result || card1.innerText == eval(card2.innerText.replace('²', '**2').replace('³', '**3').replace('⁴', '**4').replace('⁵', '**5'))) {
card1.classList.add('matched');
card2.classList.add('matched');
matchedPairs++;
if (matchedPairs === 5) {
document.getElementById('reset-button').style.display = 'block';
}
} else {
card1.classList.add('hidden');
card2.classList.add('hidden');
card1.classList.remove('flipped');
card2.classList.remove('flipped');
}
flippedCards = [];
}
function resetGame() {
cards.forEach(card => {
card.classList.add('hidden');
card.classList.remove('flipped', 'matched');
});
flippedCards = [];
matchedPairs = 0;
document.getElementById('reset-button').style.display = 'none';
}
cards.forEach(card => card.addEventListener('click', flipCard));
document.getElementById('reset-button').addEventListener('click', resetGame);
</script>
</body>
</html><!DOCTYPE html>
<html lang="nl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Memory Game</title>
<style>
body {
font-family: 'Arial', sans-serif;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
background-color: #f0f8ff;
margin: 0;
height: 100vh;
}
.memory-game {
display: grid;
grid-template-columns: repeat(5, 100px);
grid-template-rows: repeat(2, 100px);
gap: 10px;
}
.card {
width: 100px;
height: 100px;
background-color: #ff69b4;
display: flex;
justify-content: center;
align-items: center;
font-size: 24px;
border-radius: 8px;
cursor: pointer;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
position: relative;
}
.card.hidden::after {
content: '?';
position: absolute;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
background-color: #ffc0cb;
border-radius: 8px;
}
.card.flipped {
background-color: #ffc0cb;
}
.card.matched {
background-color: #98fb98;
cursor: default;
pointer-events: none;
}
#reset-button {
margin-top: 20px;
padding: 10px 20px;
font-size: 16px;
background-color: #ff69b4;
color: white;
border: none;
border-radius: 8px;
cursor: pointer;
display: none;
}
</style>
</head>
<body>
<div class="memory-game" id="memory-game">
<div class='card hidden'>2¹</div>
<div class='card hidden'>2³</div>
<div class='card hidden'>2</div>
<div class='card hidden'>2²</div>
<div class='card hidden'>8</div>
<div class='card hidden'>2⁴</div>
<div class='card hidden'>4</div>
<div class='card hidden'>2⁵</div>
<div class='card hidden'>16</div>
<div class='card hidden'>32</div>
</div>
<button id="reset-button">Speel opnieuw</button>
<script>
const cards = document.querySelectorAll('.card');
let flippedCards = [];
let matchedPairs = 0;
function flipCard() {
if (flippedCards.length < 2 && !this.classList.contains('flipped')) {
this.classList.remove('hidden');
this.classList.add('flipped');
flippedCards.push(this);
if (flippedCards.length === 2) {
setTimeout(checkForMatch, 1000);
}
}
}
function checkForMatch() {
const [card1, card2] = flippedCards;
const expression1 = card1.innerText.replace('²', '**2').replace('³', '**3').replace('⁴', '**4').replace('⁵', '**5').replace('¹', '');
const expression2 = card2.innerText.replace('²', '**2').replace('³', '**3').replace('⁴', '**4').replace('⁵', '**5').replace('¹', '');
const result1 = eval(expression1);
const result2 = eval(expression2);
if (result1 == result2 || expression1 == result2 || expression2 == result1) {
card1.classList.add('matched');
card2.classList.add('matched');
matchedPairs++;
if (matchedPairs === 5) {
document.getElementById('reset-button').style.display = 'block';
}
} else {
card1.classList.add('hidden');
card2.classList.add('hidden');
card1.classList.remove('flipped');
card2.classList.remove('flipped');
}
flippedCards = [];
}
function resetGame() {
cards.forEach(card => {
card.classList.add('hidden');
card.classList.remove('flipped', 'matched');
});
flippedCards = [];
matchedPairs = 0;
document.getElementById('reset-button').style.display = 'none';
}
cards.forEach(card => card.addEventListener('click', flipCard));
document.getElementById('reset-button').addEventListener('click', resetGame);
</script>
</body>
</html>