The following are my notes/observations about what Jen DeWalt did to complete her page:

  1. She does not actually use a button for the "click me" box. She uses a div and then styles it.
  2. The random color generator simply produces a hexadecimal color. Her function is as follows: "Math.random().toString(16).slice(2,8)"
    1. Math.random() => produces a random number between 0 and 1
    2. toString => converts the number into a string (as I am assuming the hexadecimal color can only be entered as a string). Also, by placing 16 in the parentheses, it returns a hexidecimal representation of the number.
    3. slice(x,y) => returns a part of the string starting at the character with index "x" and then stopping at and NOT including the "yth" character.
  3. The button itself has an href attribute assigned to "javascript:void(0);". That script is the smallest script that evaluates to 'undefined' which prevents Javascript from loading a new page. There are some good articles on that at Stack Overflow and Tizag.
  4. It looks like she is using JQuery for the rest of her function in 'random_background.js'. Here are my initial impressions which I will then try to validate later. The following comments are based on her function shown here:
  5. $("#button").on("click", function () {
         $('body').css('background', randomColor());

    1. "#button" is the id of her anchor tag that says "Click me!"
    2. JQuery appears to do events similar to what I've learned but breaks it up a bit. It looks like you select the thing it should watch the event for, specify the event (i.e. click), and then tell it what to this case, it's do the function.
    3. The function grabs the body and seeks to edit the css property "background" where it then puts in the randomColor() function which returns a hexadecimal value.
  6. As a reminder, "../" goes up one directory level.

Things to think about:

  1. I need to learn JQuery and compare it to how I currently understand events in Javascript.
  2. How else could I do the hexadecimal color generator? I kind of just broke down her equation and then used would I intuitively do it and do I like my version vs. hers?