Question: Write a module called prestoCard that exposes the following 3 functions and has a local variable named balance which is a non- negative number and

 Write a module called "prestoCard" that exposes the following 3 functions

Write a module called "prestoCard" that exposes the following 3 functions and has a local variable named balance which is a non- negative number and initialized with 0. (NOTE: You may assume that you're writing your module inside a separate "prestoCard.js" file) The module's three functions: loadCard(amount): This function adds the value of "amount" to the variable balance. takeBus(busType): If busType is equal to "TTC", this function decreases the variable balance by 3.25. For other busType values (which are not accepted by the transit company), this function needs to decrease the variable balance by 0.50. If negative number occurs, the balance should be set to 0. retrieveBalance(): This function will return the value of balance. Usage Example: let mycard= require("./modules/prestoCard.js"); myCard.loadCart (10); myCard. takeBus ("TTC"); myCard. takeBus ("YRT"); console.log(myCard.retrieveBalance()); // outputs 6.25 myCard. takeBus ("ITC"); myCard. takeBus ("TTC"); console.log(myCard.retrieveBalance()); // outputs modules/prestoCard.js: // Your code starts here

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!