x
 
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Car Object Example</title>
    <script>
        // Define the car object
        var car = {
            make: "Toyota",
            model: "Corolla",
            year: 2020,
            start: function() {
                document.getElementById("status").innerText = "Car started";
            },
            drive: function() {
                document.getElementById("status").innerText = "Car is driving";
            },
            stop: function() {
                document.getElementById("status").innerText = "Car stopped";
            }
        };
        // Function to display car details
        function displayCarDetails() {
            document.getElementById("car-details").innerText = 
                "Make: " + car.make + ", Model: " + car.model + ", Year: " + car.year;
        }
    </script>
</head>
<body onload="displayCarDetails()">
    <h1>Car Object Example</h1>
    <div id="car-details"></div>
    <button onclick="car.start()">Start</button>
    <button onclick="car.drive()">Drive</button>
    <button onclick="car.stop()">Stop</button>
    <p id="status"></p>
</body>
</html>