javascript functions
play

Javascript: Functions ATLS 3020 - Digital Media 2 Week 4 - Day 2 - PowerPoint PPT Presentation

Javascript: Functions ATLS 3020 - Digital Media 2 Week 4 - Day 2 Quiz #1 next Monday Structure: Topics covered: 30 minutes in-class Input/Output Open note, book, Creating arrays, deleting and internet, etc adding elements


  1. Javascript: Functions ATLS 3020 - Digital Media 2 Week 4 - Day 2

  2. Quiz #1 next Monday Structure: Topics covered: ● 30 minutes in-class ● Input/Output ● Open note, book, ● Creating arrays, deleting and internet, etc adding elements from arrays ● Write a program ● If-Else statements that follows a set of ● For loops steps ● Functions

  3. Project 1 Write a game in JavaScript. The game can be a guessing game, a calculation game, a quiz, or some other type of game. Be creative! Your project plan should include the following: Due Feb 9 description of your project ○ ○ pseudocode for algorithms and program flow ○ visual design template or example ○ brief description of how you will test your project

  4. Functions Verse 1 Verse 1 Another way that to not Chorus repeat code Verse 1 Example: Music Verse 1 Chorus Chorus Verse 1 Verse 1 Chorus

  5. Functions Javascript There are TWO key words! function do_something () { 1. You must write the word “function” // inside the function } 2. You must name the function (just like a // outside the function variable name) do_something(); Calling a function Type the name of the function with parentheses afterwards.

  6. Functions with Parameters Javascript Parameters function do_something (x, y) { ● Put the variables you want to pass inside // inside the function of the parentheses } // outside the function ● This creates two variables called x and y var a = 0; do_something(a, "red"); Calling a function ● You must have the same number of variables as parameters ● You can pass in variables or data values

  7. Lab 6 Continue playing the card game War ! 1. Copy your code from Lab 5. 2. Create a new function that plays 1 round of the game. Copy your code from inside the for or while loop and put it inside of the function. 3. Create a function that removes (with splice) the first cards from both player’s decks. 4. Create a function that prints the first cards of both player’s decks.

Recommend


More recommend