rd2705
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Tinker Week 4 - Javascript Part I Rainy Duan, Alex Jagiello and Maria Hurley ## Part 0 - What do you think is the value of definitely? - Is Jimmy going to the prom with Sally? >The value of definitely is 'yes' and Jimmy is (duh) going to the prom with Sally! Good job Jimmy! - How does this work? (Code, not relationships.) >`function yes(x){return x();}function no(x){return 'yes';}function maybe(no){return no;}var definitely = maybe(yes(no));` >Looking at the code in line 1, we get yes(no) and for return we get no(). And then no() starts and returns 'yes'. After which, maybe('yes') is run and we get "yes" as an answer. - When is the no function called? >the 'no' function is called after function yes on line 2. - On the line var definitely = maybe(yes(no)); there aren’t ()s immediately after no. What is the significance of this? >The significance of this is differentiating between an argument and function. Here the no serves as an argument and not a function being called. - Explain how this code snippet works, line by line, part by part. - Be very specific - Use important keywords - Provide explanation of what each syntax detail represents as well >First, we have a function that calls on yes(x). The return statement halts the functiona nd returns to us a value which is x(). Then the process is repeated for function no (x), which returns 'yes'. In the end, we have a var statement that declares 'definitely' as a variable. - What does the ${} syntax represent? >${} syntax represents how you would introduce a variable without concatenating. For example, ${x} is the same as " + x + ". - Why are template literals super useful for us? > Template literals are useful when we want to present complex statements that attempt to compare multiple variables. --- ## Part 1 - Click on the link at the top to view the index-simple.html version. Compare the HTML between this version and the Bootstrap version. Compare the JS between this version and the Bootstrap version. - How do these two versions compare with regard to helping you understand Javascript? >HTML: the HTML in the version with the Bootstrap has a lot more classes with the word default in them. For example:` <button class="btn btn-default" onclick="setName()">Set Name</button>` The same code in the version without the Bootstrap doesn't have the extra button class: `<button onclick="setName()">Set Name</button>` >JS: For the Javascript, I couldn't detect a difference. Both lines of code looked exactly the same to me for part 1. - Play with the interface (each of the buttons) and observe how the program reacts. When tinkering, try changing the order in which you play with the interface. Take note of the printed history. - Explain how this program works with regard to STATE, SEQUENCE, and CAUSALITY of each line, and/or specific parts of a line as appropriate. Use specific vocabulary, as demonstrated in the notes section. - Be sure to articulate both aspects of the HTML and JS. - What does the prompt function return? > The prompt function returns the information that the user inputed. For example, > `function setName() {printLog('#prePartOne', "setName called():");firstName = prompt('What is your first name?');` This allows for the state of one's first name to be presented and for following sequences of questions to occur. - Explain what you think the document.querySelector() does. Talk about this in terms of the functions vocabulary presented in the Notes. >document.querySelector() is a function that searches the inputs for the appropriate charactersitic demanded and attempts to present you with that output. - If I told you that document.querySelector RETURNS something, what do you think that something is? >document.querySelector() returns the first Element within the document that fits the specified selector/ group of selectors. - How could you alter the printName function in order to print the users first and last name in the browser window tab? >This is the original: `function printName() {var fullName = firstName + " " + lastName;}` >We think adding the prompt function would make print the first and last name in the browser window tab:` fullName = prompt('fullname');` - How would you use the makeFullName function to shorten the greetUser and printName code? >`function greetUser() {var displayName = firstName + " " + lastName;alert("Hello " + displayName + "!"); printLog('#prePartOne', `greetUser called(): ${displayName}`);}` >`function printName() {var fullName = firstName + " " + lastName;}` >`function makeFullName(first, last) {return first + " " + last;}` >Initially, I tried matching the output of var displayname to makeFullName, but I couldn't get the code to output the fullname. THen I tried shortening firstName to just first, but that also didn't work. I am not really sure how to shorten the greetUser and printName code because once I start taking things out, the code stops working. --- ## Part 2 * Play with the interface (each of the buttons) and observe how the program reacts. When tinkering, try changing the order in which you play with the interface. Take note of the printed history. >Upon initial discussion, we were working together to figure out how to print through manipulation of the DOM in the JS Bootstrap interface.By inspecting the console through the debugger mode, the interface of the buttons is visible. Through manipulation of the interface in the debug mode, we are able to see how Bootstrap interface incorporates the levels of parent and children elements into play. * Explain how this program works with regard to STATE, SEQUENCE, and CAUSALITY of each line, and/or specific parts of a line as appropriate. Use specific vocabulary, as demonstrated in the notes section. * Be sure to articulate both aspects of the HTML and JS. >While using the Bootstrap JS version we noticed that the layout of the interface is designed to start with the broad elements, and working from left to right simplifing and making the code more specific. For example, each of the buttons is nested within the same class but separate onclick properties that describe separate functions. Ex: ` <button class="btn btn-default" onclick="greetUser()">Greet User</button>` * Depending on the sequence in which the button is coded, is how the computer will interact with it. * What kind of events are happening in Part 2 and explain how this relates to when the handlers will run. >Based upon document.querySelector() and altering the printName fuction, we are experimenting with how various event handlers can be manipulated. * What is event.target? >event.target and eventTarget are native code within the programming HTML database. >The eventTarget listener is what responds when something happens within the code to cause an alert to show. * What does the dot .value, .textContent, .innerHTML represent in this context? > For exampel, .value represent the information entered by the user. The .value property tells the computer to capture and deem the information entered by the user as the value of the object, the defining features. .textContent is a property/function(?) added to the end of element properties. It tells the computer to save the information that the user inputs as its own class. In this example the algorithm is telling the computer to save the variable fullName= as the user's input of firstName + "" + lastName. The next line of the algorithm states that the (#'fullName').textContent = fullName. It serves as a bond from one variable to the next. .innerHTML represents the set code designed through HTML to serve as the structure for the element. `function printName() { var fullName = firstName + " " + lastName; document.querySelector('#fullName').textContent = fullName; printLog('#prePartOne', `printName called(): ${fullName}`); } function resetPartOne() `. ``` /// (not sure what this is / why it is here) function resetCoffee(event) { var selectEl = document.querySelector('#coffee'); selectEl.value = ""; ``` * Why does updateEmail have a parameter for event data but the other functions do not? >updateEmail has a parameter for event data while the other functions do not because the updateEmail function is linking the user with their specific email address, combining the unique data set. There is a parameter for event data which can be used to store the data and reset the form for new user interaction. * resetInfo is actually a little broken. Why? >resetInfo() represented a function containing many empty strings and "unknown person". --- ## Part 3 * Play with the interface (each of the buttons) and observe how the program reacts. Take note of the printed INFO. * Explain how this program works with regard to STATE, SEQUENCE, and CAUSALITY of each line, and/or specific parts of a line as appropriate. Use specific vocabulary, as demonstrated in the notes section. >The initial state of part 4 is a gif of a cat "shaking it's tail feather" with 7 different buttons that can be pressed as well as an INFO box to give you desired information about the image. Once you click one of the boxes, it changes the state of the INFO box to then be filled with information like tagName, src id, etc.(We tried to undertsand what element the `var mysteryEl = document.querySelector('body');` changed but it still remains a mystery, however, we can say that it doesn't change the state of Part 3). When we continued testing out the sequences of the buttons, we noticed a few changes. The first being: >![](https://i.imgur.com/JGSM5sw.png) ![](https://i.imgur.com/tPMebx5.png) >Switching around the tagName and id elements within the printLog. We left the defining characteristics like tagName and id that would show up in the INFO box however the information given in those to categories differed. ![](https://i.imgur.com/UQqtCJC.png) ![](https://i.imgur.com/s49ah0G.png) If we also changed the organization of the functions it changed the way it was organized in our tinker. The original: ![](https://i.imgur.com/1YTJ0yf.png) ![](https://i.imgur.com/YS2LVVc.png) And we changed it to: ![](https://i.imgur.com/GDsB2VQ.png) ![](https://i.imgur.com/4VLz7OV.png) It changed the information given in the INFO box. All of this to say that the sequence we recognized was not just the way the functions were written within JS, but also the sequence in which it was given in the INFO box depending on what button was pressed. The state was able to be reset by the reset button to a blank state but as soon as a button was pressed, it changed the state of the INFO box. And the causality was the ways in which we manipulated the code to see the different effects that would occur when it was manipulated. We also noticed with the "change image" button, the difference between what information (like tagname, ID, src) in the INFO box. * Be sure to articulate both aspects of the HTML and JS. >When it comes to causality, you definitely can notice the effects of HTML from the JS. When a button was pressed, it would take the information from the HTML and display it in the INFO box. For example: ![](https://i.imgur.com/fgNz4UU.png) This was the html and when you pressed the "Show Image Data (Partial)" button you would see tagName as IMG, you would see id as animalImage and that is because the JS function links: ![](https://i.imgur.com/YkBpWyu.png) We're guessing that the `printElementPartialData` function creates the printed information within the INFO box and that it links the id of the HTML to work within the JS. * Compare and contrast the `showImageData` and `showImageViaParent` functions. * How do these two different functions achieve the same output? >When we pressed the `showImageViaParent` we didnt notice that it did anything different than the Partial button. When we looked inside the coding we noticed this was the HTML code: ![](https://i.imgur.com/sk9toEh.png) And this was the JS code for it: ![](https://i.imgur.com/bR8TSLZ.png) ![](https://i.imgur.com/28CAUxR.png) Since the animalImage was inside of the div animalImageParent in the HTML code, we assumed that's what made all information within that class be a replica of information. We also noticed that within the JS, that the `showImageViaParent()` has a definition of the `parentEl` variable but doesn't have any definition further (like what is `parentEl.children[0]`? where did the "children" come from? where is the array that has 0?) so we that that may have the reason as to why the data doesn't change. * Compare and contrast the `showParentData` and `showParentViaImage` functions. * How do these two different functions achieve the same output? >Similar to the `showImageData` and `showImageViaParent` functions, the `document.querySelector()` shows the same HTML that are within the same div group which makes sense why they would have the same output. ![](https://i.imgur.com/fgNz4UU.png) ![](https://i.imgur.com/hqTEnJw.png) ![](https://i.imgur.com/C7u3C70.png) * Play with the Change Image button. * Can you modify the related code so that each time you pressed it, it would show 1 of 5 images, cycling through to the next image per click? * There are several ways to solve this. >We tried to have it cycle through 5 image but it would only change to the new image `src` that we gave it. Was thinking to give the `var imgEl` ![](https://i.imgur.com/230pM1H.png) > an array? but wasn't sure how to do that with `src`. * Play with the Show This Button button. * What is the value of the property onclick of the button? >The onclick button refers to the function within the JS. In the HTML it says `<button class="btn btn-default" onclick="showParentData()">Show Image Parent Data (Partial)</button>` and then when you look at the JS it has `function showParentData(){....}` which you can see how the onclick and the function replicate the same things. SO when you click on that button the function will "do its thing" and define the data within it (which was the #animalImageParent from the HTML). --- ## Part 4 - Challenge * Play with the interface (each of the form inputs) and observe how the program reacts. Carefully take note of what actions cause what results, in what order. ALSO, open up your Chrome Devtools and watch your inspect elements tool pane as you interact with this form. * Explain how this program works with regard to STATE, SEQUENCE, and CAUSALITY of each line, and/or specific parts of a line as appropriate. Use specific vocabulary, as demonstrated in the notes section. * Be sure to articulate both aspects of the HTML and JS. >We appreciate the way that the form input is linked to the below "results" section. The labels created by the user interaction with the form is clearly marked in conjunction with the user.textInput. The state begins with coffee being automatically populated but everything else being in a blank slate. Once you press on the choices and click save it gives you the reesults of your choices, changing the state of part 4. Also when you type into the box, it will display in the results box, ultimately changing the state of the part even if the no box is populated. The initial sequence is to answer all the questions then click save to see the results, which would be the "sequence" of events for part 4. When it comes to the code, the choices need to be selected and saved in order for the results to populate in them (which is also a causality). Another causality is the words typed within the text box. When words are typed within the text box, it appears in the result box due to `function characterTyped(e)` which correlated with with the text area's `onkeyup="characterTyped(event)` HTML code. * Explain the differences between `select`, `checkbox`, `radio`, `textarea` with regard to how we get the input values. >'Select' is when a user can choose from a series of options. 'checkbox' is the a series of boxes in which a user can select multiple values through a square representation. 'radio' is typically a form of button that allows for one selection through a circular representation. 'textarea' is the empty string ("") for user input to be added as the value (.textValue). * What is the importance of the name attribute, especially for radio buttons? >It lets the person coding know what type of butons they can use to survey a group. For example, if you want to select multiple items (like the time of day you like coffee) versus if you use the select button to represent that the user has one one item to choose between the options. It also lets us know what type of coding may be involved when having these buttons (like if we need an array, string, boolean, etc.). * Explain the significance of `e`, `banana`, `bananaEvent`, and `event`. * How are they the same and how are they different? > `e` is how you're able to see the words your are inputing in the textarea within the RESULTS box.`banana` is what saves the information that is clicked and shows them within the RESULTS box. We're not too sure what `bananaEvent` and `event` does. With `bananaEvent`, we think it correlates with the textarea because in HTML the code is `<textarea id="why" class="form-control" placeholder="Enter reasons here" onkeypress="saveCoffee(event)" onkeyup="characterTyped(event)" onblur="editingOff()"></textarea>` and the significant part is the `editingOff()` because in JS the bananaEvent is in the `function editingOff(bananaEvent)` With `event`, we think that it correlates with `<select id="coffee" class="form-control">` in the HTML since within the JS it has the function `var selectEl=document.querySelector('#coffee');` and previously the HTML correlated with the JS in the `document.querySelector()` section. * Try tinkering with some of these functions to produce some diffent looking, behaving results in the results pane. * Explain what you tinkered with and what the results were.

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully