I’m working through a course on JavaScript currently and honestly I’m having a pretty difficult time with it. If anyone has any resources they could recommend for learning, I’d appreciate it!
I’m trying to make a simple banking app with these requirements:
-
The user should see a prompt so they can type which action to perform.
-
The user will have a list of 4 actions to choose from.
-
Enter Q to quit (immediately quits the program).
-
Enter W to withdraw.
- The user will be prompted again to enter an amount to withdraw. After withdrawing money,
they should be able to type another option.
- The user will be prompted again to enter an amount to withdraw. After withdrawing money,
-
Enter D to deposit.
- The user will be prompted again to enter an amount to deposit. After depositing money,
they should be able to type another option.
- The user will be prompted again to enter an amount to deposit. After depositing money,
-
Enter B to view balance.
- The user will see their balance. Afterwards, they should be able to type another option.
- The user will see their balance. Afterwards, they should be able to type another option.
-
The balance should update after any Withdrawal or Deposit transactions.
-
The program will loop asking for input until the user enters Q.
Here’s my basic HTML for a very simple site
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<h1>Welcome!</h1>
<button onclick="start()">Click here to get started.</button>
<script src="scripts.js"></script>
</body>
</html>
And here’s as far as I’ve been able to get with the JS…
function start() {
let input = prompt('What would you like to do?');
if input = 'w' {
alert('Withdraw');
} else () {
}
}
And I know that’s probably not even the direction I need to be going. I’m honestly stuck because I don’t really know where to start. Any and all advice is much appreciated, TIA!!
>Solution :
You are trying to do a lot of things at the same time. I know, planning is key but try to go step by step. Try to be as specific as possible when asking, and go step by step when you start working.
There are many topics on this page. Stackoverflow offers a search where you can already get some help, e.g. for a first question that could be "How to create a menu to prompt for user input in Javascript".
Based on my comment above, a resulting post of interest could be Prompt for user input on Command prompt using Javascript.