Tell us what’s happening:
i cant get it to work and i tried evrything i think.
i cant pass
Your code so far
<!-- User Editable Region -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Simple Game</title>
<style>
/* CSS for the loading screen */
#loading-screen {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: #ffffff;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
z-index: 9999;
}
#loading-text {
font-size: 24px;
margin-top: 20px;
}
/* CSS for the button */
#action-button {
margin-top: 20px;
padding: 10px 20px;
background-color: #007bff;
color: #ffffff;
border: none;
border-radius: 5px;
cursor: pointer;
}
/* CSS for the hidden image */
#hidden-image {
display: none;
margin-top: 20px;
}
</style>
</head>
<body>
<div id="game">
<div id="loading-screen">
<h1>Loading...</h1>
<p id="loading-text">Please wait while the content is loading...</p>
</div>
</div>
<!-- Your website content goes here -->
<h2>Welcome to My Simple Game!</h2>
<p>This is a simple game. Click the button to reveal a hidden image.</p>
<!-- Button to trigger an action -->
<button id="action-button">Click Me!</button>
<!-- Hidden image -->
<img id="hidden-image" src="https://via.placeholder.com/400" alt="Hidden Image">
<script>
// Simulate loading process
document.addEventListener("DOMContentLoaded", function() {
// Show loading screen
var loadingScreen = document.getElementById("loading-screen");
loadingScreen.style.display = "flex";
// Simulate loading time (5 seconds)
setTimeout(function() {
// Hide loading screen
loadingScreen.style.display = "none";
}, 5000); // Adjust the time as needed
// Log "Hello World" to the console
console.log("Hello World");
});
// Function to handle button click
document.getElementById("action-button").addEventListener("click", function() {
// Show hidden image
var hiddenImage = document.getElementById("hidden-image");
hiddenImage.style.display = "block";
});
</script>
</body>
</html>
<!-- User Editable Region -->
Your browser information:
User Agent is: Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36
Challenge Information:
Learn Basic JavaScript by Building a Role Playing Game - Step 3