Made with ScholarlyMake flashcards like these from your own notes
Question:What is JavaScript primarily used for in web development?
Answer:Provides client-side behavior and logic for 99% of websites, making them interesting, interactive, and adjustable.
Question:How does JavaScript relate to HTML and CSS?
Answer:JavaScript is a programming language like HTML and CSS.
Question:What role do variables play in JavaScript code?
Answer:Variables store data or information.
Question:Give an example of data stored in a variable like a username.
Answer:Your username.
Question:What kind of data might a variable store for the price of a single t-shirt?
Answer:The price of a single t-shirt.
Question:What variable could store whether a user is logged into an account?
Answer:Whether or not the user is logged into an account.
Question:What irrational number is often stored in a variable for math calculations?
Answer:The irrational number pi.
Question:What player-related data might a variable hold in a video game?
Answer:The player character that will show up in a video game.
Question:What list of points counts as a player's hitbox in a game variable?
Answer:A list of all the points that counts as the player's hitbox in a game.
Question:What do data types refer to in variables?
Answer:The type of data that is being stored.
Question:Why is the number 2 different from the symbol "2" in data types?
Answer:They are different types stored differently in memory.
Question:What are integers in JavaScript?
Answer:Whole numbers, positive or negative.
Question:Name three examples of integer values.
Answer:• 4 • -35 • 0
Question:What are doubles in JavaScript data types?
Answer:Decimal numbers, positive or negative.
Question:Name two examples of double values.
Answer:• 3.14 • -8.1845
Question:What is a string data type?
Answer:A series of characters in a particular order, like a word or phrase.
Question:Give two examples of string values.
Answer:• "Hello" • "Bob Cat"
Question:What values does a Boolean data type hold?
Answer:Yes or no values, always written as "true" or "false".
Question:Name the two Boolean values.
Answer:• true • false
Question:What is a List/Array data type?
Answer:An array of related values.
Question:Give an example of a List/Array.
Answer:[A, B, C...]
Question:What is an Object data type?
Answer:A collection of related values.
Question:How should you read JavaScript code?
Answer:Read all code from top to bottom for the order.
Question:What does 'let name = "Obama";' declare?
Answer:A variable named 'name' with value "Obama".
Question:What does print("Thanks") output?
Answer:Thanks
Question:If name = "Obama", what does print(name) output?
Answer:Obama
Question:What is the full output of code: let name = "Obama"; print("Thanks"); print(name);
Answer:• Thanks • Obama
Question:Are semicolons required at the end of lines in this JS?
Answer:No, you can omit/ignore them as long as you write code on new lines.
Question:Why form a habit of using semicolons in JS?
Answer:Prepares for AP Comp Sci A which requires them.
Question:What is the default display command in generic JS?
Answer:console.log(THING_TO_DISPLAY)
Question:How does console.log function like print?
Answer:It functions like print, with a new line at the end of each display.
Question:What is the origin of print and println functions?
Answer:Part of a package for introductory class and transition to AP Comp Sci A.
Question:Where is (0,0) located on JS Canvas?
Answer:Top-left corner.
Question:In JS Canvas, which direction does X increase?
Answer:To the right (normal).
Question:In JS Canvas, which direction does Y increase?
Answer:To the bottom (opposite of math).
Question:Name four example points on JS Canvas.
Answer:• (0,0) • (2,3) • (1,0) • (-1,-1)
Question:What is camelCase in JS naming?
Answer:Every word is capitalized.
Question:Are all graphics in JS object data types?
Answer:Yes.
Question:How do you create a basic shape object in JS graphics?
Answer:let shape = new Shape(parameters);
Question:How do you set the color of a shape?
Answer:shape.setColor(color);
Question:How do you set the position of a shape?
Answer:shape.setPosition(x, y);
Question:How do you add a shape to the canvas?
Answer:add(shape);
Question:Where can you find documentation for specific shapes?
Answer:Step 1: 'Docs' tab on right. Step 2: Click 'documentation'. Step 3: 'Graphics' then select shape.
Question:What determines a rectangle's position?
Answer:Its upper left corner.
Question:Write the code template for creating a rectangle.
Answer:let shape = new Rectangle(width, height);
Question:What is a circle's position determined by?
Answer:Its perfect center.
Question:What is the radius of a circle?
Answer:The distance from the center to the edge.
Question:Write the code template for creating a circle.
Answer:let shape = new Circle(radius);
Question:What does stopTimer do?
Answer:Stops your animation immediately.
Question:How do you call stopTimer?
Answer:stopTimer(function_to_stop);
Question:Where should you place stopTimer in code?
Answer:Inside an if statement.
Question:What is a mouse event?
Answer:Something that happens when input is detected from a computer's mouse.
Question:Give an example of a mouse event in a video game.
Answer:When the mouse is moved, the point-of-view camera moves.
Question:Give an example of calculating with mouse clicks.
Answer:When clicking the mouse, calculate the current clicks per second.
Question:Step 1 to write mouse events: what do you create?
Answer:Write a function to describe the instructions that happen when the mouse event occurs.
Question:In mouse click CPS example, what do you track first?
Answer:Keep track of the number of clicks.
Question:In mouse click CPS, what else do you track?
Answer:Keep track of the amount of time.
Question:How do you get mouse X position in a function?
Answer:let mousex = mouse.getX();
Question:How do you get mouse Y position?
Answer:let mousey = mouse.getY();
Question:Step 2 for mouse events: what do you choose?
Answer:Choose a mouse event that starts your function from step 1. Call that function inside.
Question:Name four other mouse-related actions besides clicking.
Answer:• Holding the mouse button down • Releasing the mouse button up • Moving • Clicking AND moving (dragging)
Question:For calculating clicks per second on click, which mouse method?
Answer:mouseClickMethod(calculate_clicks)
Question:In CPS example, initialize num_clicks and time.
Answer:let num_clicks = 0; let time = 0;
Question:In calculate_clicks function, how increment clicks?
Answer:num_clicks = num_clicks + 1
Question:How compute clicks per second?
Answer:let clicksPerSecond = numClicks / time
Question:When does mouseDownMethod(fn) run?
Answer:When the mouse is FIRST held down. Continuously while holding does not run multiple times.
Question:When does mouseUpMethod(fn) run?
Answer:When the mouse is released up.
Question:When does mouseClickMethod(fn) run?
Answer:When the mouse is pressed AND released. Must be a full click to occur.
Question:When does mouseMoveMethod(fn) run?
Answer:Whenever the mouse is moved.
Question:When does mouseDragMethod(fn) run?
Answer:Whenever the mouse is pressed down, held, AND moved (dragged across the screen).
Question:Why might print be used instead of console.log?
Answer:Makes coding accessible for introductory class.
Question:What coordinate is top-left on canvas?
Answer:(0,0)
Question:Why is Y direction opposite in JS Canvas vs math?
Answer:Y increases to the bottom.
Question:What does shape.setPosition(x,y) change?
Answer:The position of the shape.
Question:Find 4 lines of code for a shape from docs.
Answer:Change relevant pieces matching previous slide.
Question:Difference between Integer and Double?
Answer:Integers are whole numbers; Doubles are decimals.
Question:Why store pi in a variable?
Answer:Used in mathematical calculations.
Question:What data type for hitbox points?
Answer:List/Array.
Question:String vs word "2"?
Answer:String is series of characters; differs in storage.
Question:Boolean always written as?
Answer:"true" or "false".
Question:Object example from text?
Answer:A collection of related values like [A, Bob Cat].
Question:Semicolons end what?
Answer:Any coding statement.
Question:console.log vs print?
Answer:console.log is generic JS default; print adds new line.
Question:What point is bottom-rightish on canvas?
Answer:(2,3)
Question:Negative coords on canvas?
Answer:(-1,-1) possible.
Question:Graphics code colored?
Answer:Will be replaced.
Question:Rectangle width/height relative to?
Answer:Upper left corner position.
Question:Circle radius from?
Answer:Center to edge.
Question:stopTimer returns?
Answer:Does NOT return any values.
Question:Place stopTimer where?
Answer:Inside if for animation stop condition.
Question:Mouse event for camera move?
Answer:Mouse move.
Question:CPS calc steps breakdown.
Answer:• Track clicks • Track time • Increment clicks • Divide clicks by time
Question:mouse.getX() returns?
Answer:Mouse X position on screen.
Question:Choose event for holding button?
Answer:mouseDownMethod
Question:Full click requires?
Answer:Press and release for mouseClickMethod.
Question:Drag needs press + ?
Answer:Held + moved.
Question:mouseDownMethod continuous?
Answer:No, only first hold, not multiple times.
Question:What happens without full release in click?
Answer:mouseClickMethod won't run.
Question:Move method for any motion?
Answer:mouseMoveMethod(fn)