Docs Viewer

Upload, preview, download, and write quick documents without Word.

+ New Document
// Get the form element const form = document.getElementById('quiz-form'); // Add an event listener to the form to detect when it is submitted form.addEventListener('submit', function(event) { // Prevent the form from being submitted event.preventDefault(); // Initialize a variable to store the user's score let score = 0; // Get the user's answers to the quiz questions const question1 = form.elements.question1.value; const question2 = form.elements.question2.value; // Add more variables here for additional quiz questions // Check the user's answers and add to the score if they are correct if (question1 === 'Paris') { score++; } if (question2 === 'New York') { score++; } // Add more checks here for additional quiz questions // Display the results to the user const results = document.getElementById('results'); results.innerHTML = `You scored ${score} out of ${form.elements.length - 1}`; });