One of my coding projects was to make a function where you told the computer how many metro rides you took and it would tell you whether to buy the monthly or the pay per ride metro card.
Before you read more heres the codepen link:https://codepen.io/coderkoji/pen/QWdVKaW
It would look something like this:
With 10 rides
You should purchase a pay per ride MetroCard! Your savings will be 99.50
That works fine when I try to run the function once but when I try to run it twice it doesnt work because the variable becomes a problem.
In order for the computer to know how many rides you took in this sentence:With 10 rides, I store it in a variable.
The directions for my coding class is: 1. Use PrintScreen()
to print the messages returned from function 2 for 30 rides, 45 rides, 60 rides, and a user-inputted custom number of rides!
The problem is that If i do printToScreen(metrocard2(20)) it wont do the sentence With numOfRides rides right. Can someone tell me if theres a way to do this without a variable or some other way that can work please