title: JavaScript Function Difficulties
body: <p>i have some code here that isn't working. And im not sure how i can make it work, some help would be awesome! </p>
  
  <p>Here's the question so you understand where i started the code from.</p>
  
  <p><strong>Question:</strong></p>
  
  <p>Use object-oriented design to design a class called PhoneBill that calculates and prints the balance owed by each customer of a phone company during the billing period. Your PhoneBill class is to receive the customer's current balance and the total time, in minutes, of phonce calls during the billing period. The input time is to be validated and the cost of calls is to be calculated at 25c per minute. Your class is to print the input balance, the phone call time, the cost of the phone calls and the total amount due.</p>
  
  <p>a. Design the class table</p>
  
  <p>b. Write an algorithm for each operation in the table.</p>
  
  <p>c. write a test or driver algorithm to test the solution</p>
  
  <pre><code>function PhoneBill()
   {
       this.bal;
       this.min;
       this.currCharge;
       this.Totaldue;
       this.currCharges=function()
       {
           this.currCharge=this.min*.25;
       }
       this.Totaldue=function()
       {
           this.Totaldue=this.bal+this.currCharge;
           return (this.Totaldue);
       }
       this.bal=function()
       {
           return (this.bal);
       }
       this.min=function()
       {
           return (this.min);
       }
   }
  
  me=new PhoneBill();
  me.balance=eval(prompt("Enter Current Balance: "));
  me.minutes=eval(prompt("Enter Minutes Used: "));
  
  document.write("Current Balance = $"+me.balance+"&lt;p&gt;");
  document.write("Minutes Used = "+me.minutes+"&lt;p&gt;");
  document.write("Current Charges = $"+me.currCharges()+"&lt;p&gt;");
  document.write("New Balance = $"+me.Totaldue()+"&lt;p&gt;");
  </code></pre>
  
  <p><strong>The Error im Having:</strong></p>
  
  <p>When i run it, i type in Current Balance (10) Minutes used (10)</p>
  
  <p>And then it prints:</p>
  
  <pre><code>Current Balance = $10
  
  Minutes Used = 10
  
  Current Charges = $undefined
  
  New Balance = $function() {return (this.bal); } NaN
  </code></pre>
  
  <p><em>What in the world did i do to this code to get it to print that?</em></p>