Download presentation
Presentation is loading. Please wait.
1
Programming in JavaScript
University of Management and Technology 1901 Fort Myer Drive, Suite 700 Arlington, VA 22009 Voice: (703) Fax: (703) Website:
2
Learning Objectives Upon completing this module, the student should be able to: Understand and Use Variables Understand and Call Functions Answer all questions at the end of Chapters 3 and 4 of the book.
3
Variables The book makes understanding variables quite easy. We’ll add a little here: Most languages have a way to define constants. A constant is a value that cannot be changed. In some languages, constants are variables that are not allowed to be changed. In some languages, constants are variables that should not be changed. In some languages, constants look like variables, but are really just values that are used by the compiler or interpreter. JavaScript does not have a way to define or use constants! Many languages require that the type of the variable be defined. For instance, in Java you might define: int x; Which means to define a variable called x and to specify that it will contain an integer. These languages are “strongly typed”. JavaScript is not “typed”, because: var x; Can contain an integer, a floating point value, a string, or anything you like.
4
Functions Likewise, the book does a good job on functions, but here’s a little more info: Many languages, especially “strongly typed” languages, make a distinction between functions and subroutines. A function returns a value of a certain type A subroutine does not return a value (in other words, it’s a function that does not return a value) Since JavaScript is not a “strongly typed” language, there is no reason to make a distinction between functions that return a value and those that don’t.
5
Your Second Graded Assignment
Using only the techniques from modules one and two, and chapters one through four of the textbook: Create two files, one named second.html and the other named second.js Write code to create a web page that uses a JavaScript program to output a NASA style count down: Ten Nine … One Ignition Start Liftoff We have Liftoff! Each line must be displayed as an alert Create a generic function that outputs one line of the countdown as an alert, and receives the data to output as an input parameter. Use that function to output each line of the countdown. Each line, after the first line, must only be output when the user clicks “Ok” in response to the alert.
6
Your Second Graded Assignment, Cont.
Use comments and lay the code out so it can be easily followed! Each file in the assignment must have a comment at the top, using the correct commenting technique for the file type, like this: Your Name Your Student ID CST140 Assignment 2 Test your program by opening the web page in your browser. You should see the NASA countdown displayed as a series of alerts (which are displayed one at a time in a popup window.) Click the OK button to display the next line in the countdown. No text is required to be written directly to the browser window.
7
Submitting Assignments for Grading
Your assignment must be uploaded to your instructor via your Student Portal. ed assignments are NOT accepted for this course! You can only upload one file per assignment. Since this assignment requires multiple files, you must create a .zip file. If you are using a recent version of Microsoft windows, you can create the ZIP file (compressed folder) by creating a new folder anywhere in your computer’s file system and putting the files in that folder. Then right-click on the folder and select “Send to” and then “compressed (zipped) folder”. Alternatively, you can use a program such as WinZIP (winzip.com). It doesn’t matter what you name the file you upload except that the file extension must be .zip.
8
Submitting Assignments for Grading, Cont.
Once uploaded you cannot upload the assignment again unless reset by your instructor – please take the time to do it right the first time!
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.