Skip to main content
Engineering LibreTexts

3.6: Exercises

  • Page ID
    27550
    1. The following is Lincoln’s Gettysburg Address. Format this using HTML in JavaScript write statements so that each paragraph is separate, and the text is centered. The lines in your program should not be longer than 80 characters.
    2. Implement a file dialog in JavaScript, and alert the file name the user has chosen, or a message if no name is chosen.
    3. Research modal and non-modal dialog boxes. Discuss the difference between a modal and non-modal dialog? When would you use each?
    4. Write a program to read two numbers from textboxes, add them together, and display the answer. Your answer should represent addition (5+6 = 11, not 56).
    5. Write a program to read two strings from textboxes, append them together, and display the answer. What does this say operator overloading of the + operator? Can you overload the + operator in JavaScript to produce new semantics? What about other operators in JavaScript?
    6. Create an array of 7 elements. Delete the 3rd element (element number 2). What happens to the array?
    7. Create an array of 10 elements (e.g. var array = new Array(10)). Try adding 11 elements to the array. What happens?
    8. Create an array of 25 numbers. Using the JavaScript array sort with a Lambda function, sort the numbers highest to lowest. You may not use the reverse method, you must use a Lambda function.
    9. Process the form you developed at the end of Chapter 2.
    10. Agree or disagree with the following statement, and give your reasons. Lambda expressions as defined in Java are not true lambda functions, but syntactic sugar to hide anonymous inner classes.