Total phone bill

During the codeX bootcamp you had to create the function below.

Write a function called totalPhoneBill that takes in a string parameter that contains calls made and sms's sent seperated with commas. Calculate the total bill for the data provided.

In the string call, sms, call, sms, sms there are 2 calls and 3 sms's.

The cost is:
  • R2.75 per call
  • R0.65 per sms
We will now use this scenario to learn how to use JavaScript in the browser to create interactive screen widgets using the DOM.

Calculate bill

Enter a string with 'call' or 'sms' seperated by commas. When the Calculate button is pressed show the total phone bill for the string entered.
Calls costs R2.75 and a SMS R0.75

If the total cost exceed R20.00 show the total cost in orange, if over R30 show it in red.

Enter bill string
Total amount: R0.00

Text input bill

Enter call or sms in the textbox. Update the appropriate total and the global total when the ADD button in pressed.
Calls costs R2.75 and a SMS R0.75
If the total cost exceed R30.00 show the total cost in orange, if over R50 show it in red.

Totals
Call total R00.00
SMS total R00.00
Total R00.00

Radio button bill

Select the call or sms radio button. Update the appropriate total and the global total when the ADD button in pressed.

Calls costs R2.75 and a SMS R0.75
If the total cost exceed R30.00 show the total cost in orange, if over R50 show it in red.

What is the benefit of using radio buttons?

Bill type
Totals
Call total R0.00
SMS total R0.00
Total R0.00

Bill with settings

Select the call or sms radio button. Update the appropriate total and the overall total when the ADD button in pressed.

Calls costs should now be configurable using the settings section.

If the total cost exceed the warning level show the total cost in orange, if it exceeds the critical level show it in red and prevent any new costs from being added. The warning and critical level should both be configurable now.

Bill type
Totals
Call total R34.00
SMS total R7.35
Total R41.35
Settings