Create a simple ATM Simulation program using JavaScript (no UI, only prompt() and alert() dialogs).
Start with a Default Balance
let balance = 1000;
This represents the userβs account balance.
Ask for a PIN
prompt() to ask the user for their PIN.const correctPin = "1234";).alert("Incorrect PIN!") and stop the program.Show the Main Menu
Once the correct PIN is entered, display a menu using a prompt():
let choice = prompt(
"Welcome to JS ATM π³\n\n" +
"1οΈβ£ Check Balance\n" +
"2οΈβ£ Withdraw\n" +
"3οΈβ£ Deposit\n" +
"4οΈβ£ Exit\n\n" +
"Enter your choice (1-4):"
);
Handle Each Option
Option 1 β Check Balance
β Show the current balance using alert("Your balance is: $" + balance);
Option 2 β Withdraw
β Ask how much to withdraw (prompt()),
β If the amount is more than the balance, show alert("Insufficient funds!")
β Otherwise, subtract it from balance and show alert("Withdrawal successful! New balance: $" + balance);
Option 3 β Deposit
β Ask how much to deposit (prompt()),
β Add it to balance,
β Show alert("Deposit successful! New balance: $" + balance);
Option 4 β Exit
β Show alert("Thank you for using the ATM!") and end the program.
Invalid Input
β If the user enters anything other than 1β4, show alert("Invalid option!").
Enter PIN: 1234
β Welcome to the ATM!
1. Check Balance
2. Withdraw
3. Deposit
4. Exit
User chooses 2 β Withdraw
Enter amount: 200
β Withdrawal successful! New balance: $800