I need to write a function, but have no idea where to begin here are the first two steps:
A global variable named customertype should be created outside of the functions. This variable will be initialized with a value (i.e. customertype = "direct" ) and will be used by the functions below.
A function named "changetype()". The function will change the customer type each time it is run. It should change "direct" to "advertising", "advertising" to "subscription" and "subscription" to "direct". It does NOT do all three at the same time, it would take three calls to the function to change the value of customertype three times. Here is how I suggest you do this:
Create a local variable named newtype at the top of the function by using the keyword 'var'
Use three javascript 'if' statements to examine customertype and assign a new value to the local variable newtype
After the 'if' statements, assign the value in newtype to the global variable customertype
An alert at the end of the function informing the user the customer type has change will be useful, especially if it shows the new value stored in customertype.
Tags: