Lab3(1) - CENG 256 Internet Programming LAB 3 This lab does not have to be uploaded Learning Objectives 1 Understand the use of 1 and 2 dimensional

Lab3(1) - CENG 256 Internet Programming LAB 3 This lab does...

This preview shows page 1 - 4 out of 12 pages.

CENG 256 Internet Programming LAB 3 This lab does not have to be uploaded.
Image of page 1
Learning Objectives: 1. Understand the use of 1 and 2 dimensional arrays a program. 2. Understand how objects are created and used in JavaScript. 3. Understand basic techniques to manipulate the DOM. Question 1: Part 1: Carefully consider the JavaScript object definition below. var hyundai = { make: Hyundai , model: SantaFe , year :2010, color: blue , passengers:5, convertible:false, mileage:89000 }; Part 2: Write a JavaScript function called printCarInfo , that prints all the information of a car object that is passed to it. Test your function with the variable Hyundai. Part 3: Add the following HSFengine object to your code. var HSFengine= { type:'V6', size:3.5 }; Now add this engine to your Hyundai object by adding the line.. hyundai.engine=HSFengine; Part 4: Write a JavaScript function called printCarInfoComplete , that prints all the information of a car object that is passed to it including the engine information. Test your function with the variable Hyundai. Important Note: You can add or delete properties at ANY time in JavaScript
Image of page 2
To delete a property you use the special keyword “delete”. For example, to delete the “convertible field” from the Hyundai object we created simply put : delete hyundai.convertible; This will not just delete the value, but the property itself. Note if you try to access the property you will simply get “undefined”. Delete returns true once if the property was deleted successfully or if it doesn’t exist in the object. It will return false only if it cannot delete the property which could happen if it is a protected object by the browser. Part 5:
Image of page 3
Image of page 4

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture