This JavaScript application manages the balance of an account by allowing users to deposit money, withdraw money, or exit the program. It continuously displays the current balance and provides options to the user until they choose to exit.
- Display Balance: Shows the current balance of the account.
- Deposit Money: Allows the user to add a specified amount to the account balance.
- Withdraw Money: Allows the user to subtract a specified amount from the account balance, with a check to ensure sufficient funds.
- Exit Program: Ends the program when the user chooses to exit.
To run this JavaScript exercise, follow these steps:
-
Save the JavaScript Code:
- Copy the JavaScript code into a file named
index.js
.
- Copy the JavaScript code into a file named
-
Create an HTML File:
- Create an
index.html
file and include the JavaScript file within a<script>
tag:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Money Management</title> </head> <body> <script src="moneyManagement.js"></script> </body> </html>
- Create an