WEB150 » Week 03: Assignment – Functions
Assignment: Week 3 - Functions
Create a function that accepts two variables as arguments, compares their numerical values and writes the result on the page. Call the function 3 times with the following values:
Tools you will need:
- Function declaration
- Function call
- Conditional Statements
- Comparison operators
Add an additional element to this page so that it does something else interesting.
- What happens if you pass in 2 strings to the function?
- What about 1 string and 1 number?
- What if the function only receives 1 argument? Can you make a case to handle it? What about no arguments? or 3? (hint: use the 'arguments' array)
- Advanced: Can you make a form so that anyone can enter any numbers they want into the function? (you will need to evaluate document.forms.fieldID.value) -- we will go over forms later :)
- What else can you make this function do?
Publish this page on your Assignments Page by next week's lecture