Assignment 4

Back to Lesson # 4 - Functions Review Questions Back to Main Menu

 

1. Use Cloud9 to create and test the greeting function described in the lesson. First write the function definition and place the code in the <HEAD> section. Then create an input text box to get the user's name and call the function when the box loses focus. Test your function in a browser.

2. Modify the function in question 1 so it can make a little change in the user's name. Have it use 'var' to declare a function variable(var capsName;). Assign the value of the input box to be stored in the variable as all upper case letters. How can you do that? Use the function called toUpperCase(). It is a member of the string object, so to use it, type the name of the string variable (the object), followed by the dot, and the method name 'toUpperCase();'.

( capsName = userName.toUpperCase();)

Notice that we are sending information to this pre-written function. Then display the name in the greeting in capital letters.

3. Write and test the function called 'getSerial()' that is described in Lesson #4. This is good practice for returning a value from a function.

Return to Top of Page | Back to Main Menu