WDV2221 Intro Javascript
Unit-4 Assignment - Functions with Parameters
Directions:
Problem 1
a. Create a global variable called schoolName. Assign it an initial value of "Des Moines Area Community College".
b. Create a function called processString( ).
- the function will accept one input parameter called inValue
- use the String.length property to display the number of characters to the console
- use the toUpperCase( ) to display the string in capital letters to the console
- display the first five letters of the string to the console
c. Call this function using a button and the onclick event handler. Pass in the schoolName variable as the parameter.
Problem 2
a. Create two global variables. One called name1 and assign it a value of "Mary". The other called name2 and assign it a value of "Smith".
b. Create a function called printName( ).
- the function will accept two parameters, firstName and lastName.
- concatenate the names into a single string formatted as "firstName lastName" and display the result to the document
- concatenate the names into a single string formatted as "lastName, firstName" and display the result to the document
- concatenate the names into a single string formatted as "lastName(all capitals), firstName" and display the result to the document
c. Call this function during runtime. Pass in the name1 and name2 variables as the parameters.