Quiz

  1. Not about the reading, but where can we find the collaboration spreadsheet for this week's assignment?

    D'oh! I'm so sorry. I meant to update this assignment and I missed it.

    In the past, I had a lot required pair-programming, but for various reasons (mostly student demand), I have discontinued it. I have no plans for pair-programming this semester.

  2. What do you mean when you say an event object will contain a code property that is the number of that key on the keyboard? In the example, it says eventObj.code === 'Escape', but 'Escape' isn't a number?

    Good catch! I meant to say a string describing that key on the keyboard.

    I've updated that part of the reading, so let's go back to it: keyboard events

  3. If I press a key down and hold, is "keyDown" being called a thousand times or is it just the first time?

    Great question! Just once, when it goes down.

  4. Are there specific times when animations can be useful and/or are expected or are they purely for entertainment/visual purposes?

    Another good question. For certain games, the animation is pretty much essential. For example: jelly blobs

    In most cases, you are correct: it's just eye candy. For example, in Google Docs, when the file is automatically saved to the server, there's a bit of text that says "all changes saved" and then that fades out in a brief animation.

  5. why don't we need quotes around height in this operation? .css({height: "50px", "font-size": "10px"})?

    Close reading! Unlike Python, JavaScript's dictionary syntax only requires keys to be quoted if they don't look like identifiers (e.g. contain spaces, start with a number...). Otherwise, you don't need the quotation marks. The following are the same:

    
        d1 = {"a": 2, 'b': 3};
        console.log(d1);
        d2 = {a: 2, b: 3};
        console.log(d2);
    
    
  6. Would you be able to speak more about when to use a closure variable and its purpose?

    Sure. It's when a function needs some additional or custom information to do its job. See next.

  7. Just having a bit of a hard time with the idea of non-local non-global variables

    Absolutely. Here's some examples:

    
        const nums = [1, 10, 100, 1000];
        function twoMore(arr) { return arr.map(x => x+2) };
        function someMore(arr, incr) { return arr.map(x => x+incr) };
        function makeIncrementer(incr) { return x => x+incr }
        nums.map(makeIncrementer(3));
    
    
  8. I am wondering whether every inner function is a closure, or only when it uses variables from the outer function?

    An inner function is only a closure if it references a non-local, non-global variable.

  9. What is the exact definition of closure? Since we saw it multiple times, I have not found how it changes how we build a function or a code line

    A closure is a function that references a non-local, non-global value.

  10. No particular questions at this time. / No questions!

    Amazing!