<button id="button-1">#1</button>
<button id="button-2">#2</button>
<button id="button-3">#3</button>
<div id="result"></div>
<script>
document.addEventListener('DOMContentLoaded', () => {
let userAnswers = [];
const rightAnswers = ['button-2', 'button-3', 'button-1'];
const resultContainer = document.querySelector('#result');
document.querySelectorAll('button').forEach(button => {
button.addEventListener('click', () => {
resultContainer.style.border = 'none';
resultContainer.textContent = '';
userAnswers.push(button.id);
if (userAnswers.length >= rightAnswers.length) {
const isRightCombination = JSON.stringify(userAnswers) === JSON.stringify(rightAnswers);
resultContainer.style.border = '1px solid ' + (isRightCombination ? 'green' : 'red');
resultContainer.textContent = isRightCombination ? 'Right' : 'Wrong';
userAnswers = [];
}
});
});
});
</script>