please wait

  • Arminder Gill Mar-15-2019 05:46:34 AM ( 2 months ago )
    var initialBalance = prompt("Initial balance:");
    initialBalance = parseInt(initialBalance);
    var choice = prompt("Deposit, Withdraw, Balance");
    choice = choice.toUpperCase();
    if (choice = D) {
      var deposit = prompt("Deposit amount:");
      alert(deposit + initialBalance);

    My code allows for the user to input information but it doesn't seem to register what has been inputted because it straight up ignores the if condition and goes to a blank page. Not sure how to get my if statements to work.
  • Atul Kasana Mar-15-2019 05:47:45 AM ( 2 months ago )

    Because you have no variable named D - you want to check against the string "D". Also use the == (comparison) operator rather than the = (assignment) operator:

    if (choice == "D") {...}
  • Alex Wilson Mar-15-2019 05:49:44 AM ( 2 months ago )

    Convert the inputs to Number from string, In the if condition make the D a string and also use == for comparison

    if (choice=='D')
        </span><span class="pln">Assignment 6</span><span class="tag">

Please login

Similar Discussion

Recommended For You