arashichan
  • NEW!
    NEW!  Connect Ideas Across Notes
    Save time and share insights. With Paragraph Citation, you can quote others’ work with source info built in. If someone cites your note, you’ll see a card showing where it’s used—bringing notes closer together.
    Got it
      • 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 No publishing access yet

        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.

        Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

        Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

        Explore these features while you wait
        Complete general settings
        Bookmark and like published notes
        Write a few more notes
        Complete general settings
        Write a few more notes
        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 No publishing access yet

    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.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    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
    1
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Coding Notes - freeCodeCamp ## Cat Application Thingy HTML elements have opening tags like < h1> and closing tags like < /h1> - note: the tags do not have a space between < and h1 Text for an element goes between opening and closing tags h1 to h6 elements signal importance. lower numbers are higher importance. only one h1 element per page p element is used to create paragraph of text on websites Commenting allows one to leave messages without affecting browser display and allows one to make code inactivev. - HTML comment starts with < ! - - (no spaces) and ends with --> HTML5 has some elements that identify different content areas. These elements hmake your HTML easier to read and help with SEO - adding < main > (no spaces) after opening tag and < /main > (no spaces) after an element ![](https://i.imgur.com/WHS8hBu.png) Above, h2 and main p elements are "Nested" inside of the main element. These should be indented two spaces farther to the right of the element they are nested in. This is calle dindentation and is used to make HTML easier to read ![](https://i.imgur.com/iRSYUse.png) Images can be added to website by using the img element. img elements have opening tag and no closing tag -- these types of tags are known as "self closing tags" ![](https://i.imgur.com/V3FleG3.png) Attributes in HTML are special words used inside of opening tag of an element to control its behavior. - SRC attrib in img element specifies images URL - ![](https://i.imgur.com/6AH40J7.png) Alt attributes are displayed if image failes to load. All img elements should have alt attribute ![](https://i.imgur.com/WxDrzV8.png) Anchor (a) element links to another page ![](https://i.imgur.com/nHbM8yP.png) Link's text must be placed between opening and closing tags of anchor element ![](https://i.imgur.com/SiuY9Z4.png) Text before anchor and after anchor will determine what gets hyperlinked ![](https://i.imgur.com/nT9TNdl.png) Adding target attribute with value _ blank (no space) to the anchor elements opening tab to make link open a new tab ![](https://i.imgur.com/qrzKLGa.png) To turn an image into a link: ![](https://i.imgur.com/fwQp2v4.png) Section element separates current content from future content ![](https://i.imgur.com/N8i11kE.png) Adding a new section under the first section: ![](https://i.imgur.com/GIqwVww.png) Adding h2 element in the second section: ![](https://i.imgur.com/ZHpZnA9.png) Adding a third element: ![](https://i.imgur.com/fYjbvhW.png) ul element is unordered list: ![](https://i.imgur.com/sLceWJV.png) li element is list item: ![](https://i.imgur.com/6Rq8RPf.png) Adding new image after unordered list: ![](https://i.imgur.com/2RYHtdb.png) Figure element represents self contained content and will allow you to associate an image with a caption. To nest the image into a figure element: ![](https://i.imgur.com/fucNAUJ.png) A figure caption is used to add caption to describe images within figure element. The element is figcaption ![](https://i.imgur.com/45MM5UO.png) em element is emphasize. To emphasize a word: ![](https://i.imgur.com/fj672TI.png) Adding another h3 element: ![](https://i.imgur.com/gmVu8W7.png) ol is ordered list element: ![](https://i.imgur.com/JgcJTJc.png) Add another figure element after the ordered list: ![](https://i.imgur.com/F0hBc2J.png) Nest another img element in the new figure element: ![](https://i.imgur.com/MfBG4ba.png) Add alt attribute to new img element: ![](https://i.imgur.com/gs1aBMX.png) Add figcaptionelement to new img element: ![](https://i.imgur.com/fVHo1Na.png) The strong element is used to indicate that some text is of strong importance or urgent. To make a word strong: ![](https://i.imgur.com/Im9hLpg.png) Add another section: ![](https://i.imgur.com/emxLK3g.png) Add h2 element to new section: ![](https://i.imgur.com/Xo8pP1A.png) Add a web form to collection information about users: ![](https://i.imgur.com/5TcpBem.png) The action attribute indicates where form data should be sent: ![](https://i.imgur.com/9qT3SKk.png) Input element enables several ways to collect data from web form. Similar to img elements, input elements are self closing and do not need closing tags ![](https://i.imgur.com/TfudhRW.png) The type attribute enables many kinds of inputs such as password field, reset button, or a control to let users select a file from their computer ![](https://i.imgur.com/beJzBL0.png) Give a name attribute to assign it a value to represent the data being submitted ![](https://i.imgur.com/LsPixWn.png) Placeholder texted used to give hint about what info to enter as input ![](https://i.imgur.com/dX3AfHB.png) the required attribute in an input element will make it so users cannot submit form without providing information that is required ![](https://i.imgur.com/8qyFXCc.png) The button element creates a clickable button ![](https://i.imgur.com/iiNIP0k.png) Something about type attribute, idk: ![](https://i.imgur.com/DsAlHly.png) Radio buttons can be used for questions where you only want one answer out of multiple options ![](https://i.imgur.com/b9NeOXM.png) Label elements are used to help associate text for an input element with the input itself. ![](https://i.imgur.com/uW203EN.png) ID attribute is used to identify specific HTML requirements. each ID attributes value must be unique from all other ID values for the entire page. ![](https://i.imgur.com/g0Qbh10.png) Make new radio button ![](https://i.imgur.com/3kMLmIt.png) Do another thing: ![](https://i.imgur.com/t56aTjM.png) And another thing: ![](https://i.imgur.com/DVWfqQT.png) fieldset eleemnt used to group inputs and labels together in a web form. these are "block-level" elements which means they appear on a new line ![](https://i.imgur.com/JvJ9xTO.png) legend element acts as a caption for the content in the fieldset element. it gives users context about what htey should enter into that part of the form ![](https://i.imgur.com/hEPsjQz.png) add a new fieldset ![](https://i.imgur.com/97SqGd2.png) do a thing: ![](https://i.imgur.com/pHyB4MH.png) Checkboxes are also things: ![](https://i.imgur.com/W0oKkyQ.png) Am tired: ![](https://i.imgur.com/YevlQal.png) This one was a bit hard: ![](https://i.imgur.com/dTuRw0G.png) add name attribute ![](https://i.imgur.com/2WLsfsG.png) add another checkbox, for lazy instead of for loving ![](https://i.imgur.com/ghFyDyQ.png) add another checkbox, this time for energetic, which I currently am not ![](https://i.imgur.com/CHl03Pt.png) more stuff: ![](https://i.imgur.com/PRxSxgx.png) make button options selected by default: ![](https://i.imgur.com/21oIgKD.png) add a footer element: ![](https://i.imgur.com/szEiGpM.png) add a p element (paragraph) to add some relevant info to footer:![](https://i.imgur.com/RttM6gl.png) make freecodecamp.org enclosed within anchor element pointed to site ![](https://i.imgur.com/2qTME1l.png) Add head element above the body element, which contains all elements rendered to page ![](https://i.imgur.com/alCgKIT.png) Add title within the head element: ![](https://i.imgur.com/eWWIih4.png) set language to english ![](https://i.imgur.com/kSPmlMv.png) do a thing: ![](https://i.imgur.com/6xivKoA.png) enable multiple languages ![](https://i.imgur.com/t5Zaq9I.png) ## Introduction to JavaScript ### comments // is an inline comment that will tell JS to ignore remainder of text for current line /* to open comment for a multi line comment and to close it is */ ![](https://i.imgur.com/15NRbuR.png) ### data types JS provices eight different data types 1) undefined 2) null 3) boolean 4) string 5) symbol 6) bigint 7) number 8) object ### variables Variables allow computers to store and manipulate data dynamically. This is done through usin ga label to point to data rather than data itself. All 8 data types can be stored as variables; they should be thought of as similar to X and Y in math Tell JS to create or declare a variable by putting the keyword var in front of it - statments end with semicolons; variables can be numbers or letters but may not contain spaces or start with a number Create "myName" variable: ![](https://i.imgur.com/Ur2osTI.png) in JS "=" is the assignment operator; we can store value in variable with it. Ex) ![](https://i.imgur.com/9SmNMfG.png) Another example: ![](https://i.imgur.com/S1szhfY.png) - this code creates variable named myVar then assigns 5 to myVar. Now when myVar appears in the code again, the program will treat it as if it is 5 Assign the value 7 to variable a: ![](https://i.imgur.com/lEinhLD.png) values of multiple variables can be assigned together though using the assignment operator (=) ... ex) var myVar; myVar = 5; var myNum; myNum = myVar; - this declared myVar with no value, then gives value 5, then declare myNum with no value, then gives myNum value of myVar Assign the contents of variable a to variable b ![](https://i.imgur.com/jvhvQmB.png) Variables can be "initialized" in the same line that they are created. EX) var myVar = 0; - this creates myVar with value of - Define a variable of a initialized to value of 9 ![](https://i.imgur.com/PTyEpJd.png) Strings can also be defined as a variable. A "string literal" is a series of zero or more characters enclosed in single or double quotes. EX) var myName = "your name"; Create two new string variables: myFirstNname and myLastName and assign them values of first and last name: ![](https://i.imgur.com/FBrlrqG.png) Variables have initial value of undefined. doing math on it will give you NaN result, "Not a Number" Initializae 3 variables a b and c with 5 10 and "I am a" ![](https://i.imgur.com/v9NftWr.png) ### case sensitivity ALL VARIABLES AND FUCNTION NAMES ARE CASE SENSITIVE MYVAR is not MyVar nor myvar. Possible that you have multiple distinct variables with same name but different casing - strongly rec'd to not use this practice camelCase is best practice. multi word variable names have first word all lower, then first letter of each subsequent word is capitalized. EX's) var someVariable; var anotherVariableName; var thisCariableNameIsSoLong; ![](https://i.imgur.com/f5bFktg.png) ### let and const variable creation In larger codebases var can become troublesome due to how easy it is to overwrite variable declarations. new keywords introduced to declare variables - keyword let is variable with same name that can only be used once - keywork const is also new way to declare variables - variables declared with const are read only; they assign a constant value; values assigned with const cannot be reassigned Always use const to declare variables that you don't want to re assign - common practice of devs to use uppercase variable IDs for immutable values and cameCase for mutable values (objects and arrays) ![](https://i.imgur.com/VaTNmVb.png) ### numbers Number is data type in JS for numeric data - const myVar = 5 + 10; - const myVar = 12 - 6; - const myVar = 13 * 13; - const myVar = 16 / 2; ### numeric operators The "++" operator can add or increment to a variable. Ex) - i++; // is the equivalent of - i = i + 1; ![](https://i.imgur.com/ue6QQHe.png) ![](https://i.imgur.com/ETrgUu4.png) The "--" operator can decrement or decrease variable by 1. Ex) - i--; // is the equivalent of - i = i - 1; ![](https://i.imgur.com/UXRA94p.png) ![](https://i.imgur.com/t9KrUBj.png) Decimals can be stored in variables as well. they are called "floating point" numbers or "floats" ![](https://i.imgur.com/BepfGPq.png) ![](https://i.imgur.com/DC2u8t7.png) ![](https://i.imgur.com/CTySgRd.png) ![](https://i.imgur.com/q6Td5fO.png) ![](https://i.imgur.com/MSEiWwv.png) ![](https://i.imgur.com/qjkVnTw.png) ![](https://i.imgur.com/3cWMIXu.png) The remainder operator "%" gives the remainder of the two division of two numbers. EX) - 5 % 2 = 1 because - Math.floor(5/2) = 2 (Quotient) - 2 * 2 = 4 - 5 - 4 = 1 (Remainder) Remainder can be used to check if number is even or odd by checking the remainder of the division of the number by 2. Ex) - 17 % 2 = 1 (17 is odd) - 48 % 2 = 0 (48 is even) Note: remainder operator is sometimes called the modulus operator; this is false; it is similar, but does not work well with negative numbers ![](https://i.imgur.com/5zl851u.png) ![](https://i.imgur.com/OT7LuMw.png) ![](https://i.imgur.com/1YJOWpx.png) ### compound assignment with augmented addition common to use assignments to modify the contents of a variable. remember that everything to the right of the equals sign is eval'd first. Ex) - myVar = myVar = 5 // this adds 5 to myVar Opeartors which do both a mathematical operation and assignment in one step. += operator will do this. ex) - let myVar = 1; - myVar += 5; - console.log(myVar); // 6 would now be displayed in the console ![](https://i.imgur.com/GF0vE4d.png) ![](https://i.imgur.com/l5NMU21.png) ### augmented subtraction -= subtracts a number rom a variable. ex) - myVar = myVar - 5; // this will subtract 5 from myVar - myVar -= 5; // this is how to re write it ![](https://i.imgur.com/Dm0SLp8.png) ![](https://i.imgur.com/36S18TS.png) ### augmented multiplication ![](https://i.imgur.com/4r2ldNb.png) ![](https://i.imgur.com/nk7QmFr.png) ![](https://i.imgur.com/LAeNRFe.png) ### augmented division ![](https://i.imgur.com/H7FQryd.png) ### escaping literal quotes in strings strings must start and end with single or double quote. what happens when you need a literal quote inside of string? to do this you can escape overarching quote with \ before each of the new quotes, to tell JS should appear inside the string as its own string. Ex) - const sampleStr = "Alan said, \"Peter is learning JavaScript\"."; - Alan said, "Peter is learning JavaScript". // this would appear in console ![](https://i.imgur.com/OL4gztV.png) ![](https://i.imgur.com/yNT7gaz.png) ![](https://i.imgur.com/9tmn6Dw.png) ### quoting strings with single quotes strings can be single or double quotes, but must be consistent per string. they work the same in JS, unlike other languages. ex) - const doubleQuoteStr = "This is a string"; - const singleQuoteStr = 'This is also a string'; you might want to use one or the other based on if you want to use both in a string. might happen if you want to save a convo in a string and have the convo in quotes. another use for it would be saving an < a > (no spaces on that tag) tag with various attributes in quotes, all within a string. ex) - const conversation = 'Finn exclaims to Jacke, "Algebraic!"'; - this is a problem if you need to use outermost quotes within it - const goodStr = 'Jake asks Finn, "Hey, let\'s go on an adventure?"'; - const badStr = 'Finn responds, "Let's go!"'; - this will return error because no \ in front of the ' of let's ![](https://i.imgur.com/U2XgQrL.png) ![](https://i.imgur.com/Q8yy9bj.png) ![](https://i.imgur.com/rwE6HQb.png) ### escape sequences in strings quotes are not only characters that can be escaped inside strings two reasons to use escaping characters: 1) to allow you to use characers you may not othersie be able to type out, such as a carriage return 2) to allow you to represent multiple quotes in a string without JavaScript misinterpreting what you mean ![](https://i.imgur.com/SqckGSu.png) ![](https://i.imgur.com/3QpYRw7.png) ![](https://i.imgur.com/GILr1CX.png) ![](https://i.imgur.com/UxUVcG4.png) ### concatenating strings with plus operator when + opeartor is used with a string value, it is called the concatenation operator. new strings can be built out of other strings by concatenating them together. ex) - 'My name is Alan,' + 'I concatenate.' - const ourStr = "I come first. "= "I come second."; - the string I come first. I come second. would be displayed in the console ![](https://i.imgur.com/AkvJpLN.png) ![](https://i.imgur.com/CODlWcs.png) ### plus equals concatenating += can also be used to concatenante a string onto the end of an existing string. this can be helpful to break a long string over several lines.ex) ![](https://i.imgur.com/slyVojr.png) ![](https://i.imgur.com/BumkncT.png) ![](https://i.imgur.com/Gfz3j9J.png) ![](https://i.imgur.com/gc6MUuo.png) ### constructing strings with variables ![](https://i.imgur.com/2v4hlKz.png) ![](https://i.imgur.com/wIzRAxc.png) ![](https://i.imgur.com/wgu2Txg.png) ![](https://i.imgur.com/tOL0FHO.png) ### appending variables to strings we can append variables to strings useing the += operator. ex) - const anAdjective = "awesome!"; - let ourStr = "freeCodeCamp is "; - our Str += anAdjective; - ourStr would have the value freeCodeCamp is awesome!. ![](https://i.imgur.com/88ZMGSt.png) ![](https://i.imgur.com/EBc4ZMT.png) ![](https://i.imgur.com/sA2EU6E.png) ### find the length of a string you can find the value of a string value by writing .length after the string variable or string literal. ex) - console.log"Alan Peter".length); - the value 10 would be displayed in the console. note that the space between alan and peter is counted ![](https://i.imgur.com/JfQyPTc.png) ![](https://i.imgur.com/AiLVOPi.png) ![](https://i.imgur.com/Fj1P1tp.png) ### bracket notation this is a way to get a character at a specific index within a string. JS + most languages start counting at 0. this is called zero based indexing. ex) - index 0 of the word charles is C - if const firstName = "Charles" then you get value of first letter of string with firstName[0] - const firstName = "Charles"; - const firstLetter = firstName[0]; - firstLetter would have a value of the string C ![](https://i.imgur.com/l3kWZYO.png) ![](https://i.imgur.com/xkk5E1M.png) ### string immutability string values are immutable -- they cannot be altered once created. ex) - let myStr = "Bob"; - myStr[0] = "J"; - this cannot change change value of myStr to Job because myStr cannot be altered the only way to change myStr would be to assign it with a new string. ex) - let myStr = "Bob"; - myStr = "Job"; ![](https://i.imgur.com/9a9mmwC.png) ![](https://i.imgur.com/Zv2MapX.png) ![](https://i.imgur.com/oAg9ssI.png) ### bracket notation to find the Nth character in a string can be used to get characters at other positions than 0 remember computers start counting at 0 ![](https://i.imgur.com/LcXvOZv.png) ![](https://i.imgur.com/Ccm960G.png) ![](https://i.imgur.com/W8q2YZe.png) ![](https://i.imgur.com/db1scZO.png) ### bracket notation to find the last character subtract one from the strings length ![](https://i.imgur.com/SCkbwau.png) ![](https://i.imgur.com/Q4FS5yp.png) ![](https://i.imgur.com/NaKWiyF.png) ![](https://i.imgur.com/v3Kky19.png) ### bracket notation to find nth to last character ![](https://i.imgur.com/iTddMpM.png) ![](https://i.imgur.com/AUnrl2K.png) ![](https://i.imgur.com/oeANRv3.png) ### word blanks ![](https://i.imgur.com/PDTGaHo.png) ex) const sentence = "It was really " + "hot" + ", and we " + "laughed" + " ourselves " + "silly" + "."; ![](https://i.imgur.com/3FmNyWP.png) ![](https://i.imgur.com/ES6fVvH.png) NOTE: console.log(wordBlanks) was used in order to display the value of wordBlanks which helped me figure out where the spacing issues were on the code ### Javascript Arrays with array variable several pieces of data can be stored in one place ![](https://i.imgur.com/0rDREMJ.png) ![](https://i.imgur.com/q8CkUbZ.png) ![](https://i.imgur.com/omNPJXv.png) Array nesting is a thing ![](https://i.imgur.com/wSfhGhh.png) ![](https://i.imgur.com/7Hpyc7y.png) ### Access Array Data with Indexes ![](https://i.imgur.com/HAMF45C.png) ![](https://i.imgur.com/0zI5Fic.png) ![](https://i.imgur.com/mfviwRM.png) ### Modify Array Data with Indexes ![](https://i.imgur.com/IqbiPse.png) - arrays are mutable! ![](https://i.imgur.com/QmVIBKm.png) ### Multi Dimensional Arrays with Indexes ![](https://i.imgur.com/j8683uF.png) ![](https://i.imgur.com/5iwN9Kh.png) ![](https://i.imgur.com/Gmrr1Xg.png) ### push() function push makes appending data to end of an array easy function is .push() - it pushes one more more parameters on to the end of an array ![](https://i.imgur.com/v9aJ7uu.png) ![](https://i.imgur.com/ApsQMwU.png) ### pop() function this can also be used to manipulate data in an array basically it will take the last element of an array and then return it as a re assigned variable ![](https://i.imgur.com/BNzGVQF.png) ![](https://i.imgur.com/azUfcdW.png) ![](https://i.imgur.com/fJLCXfH.png) ### shift() function pop function always removes the last element of an array shift will remove the first instead of last .shift() ![](https://i.imgur.com/0PsWwbw.png) ![](https://i.imgur.com/kau3xeW.png) ### unshift() unshift is like push except it adds stuff to the beginning of an array rather than to the end of one ![](https://i.imgur.com/PWCv3kG.png) ![](https://i.imgur.com/wn4feCg.png) ### Shopping List Challenge ![](https://i.imgur.com/Dpwv1tx.png) ![](https://i.imgur.com/zuT9EC0.png) ### Functions code can be divided up into reusable parts called functions ![](https://i.imgur.com/bLlDphx.png) ![](https://i.imgur.com/jN4Z460.png) ![](https://i.imgur.com/xvAqXVX.png) ### Values to Functions with Arguments ![](https://i.imgur.com/QgHiA3U.png) ![](https://i.imgur.com/4KX71HD.png) ### Return Value from a Function ![](https://i.imgur.com/qCaXnxn.png) ![](https://i.imgur.com/EGi2t8W.png) ### Global Scope and Functions scope is the visibility of variables variables defined outside of a function have global scope this means they can be seen everywhere in JS code - declared variables without let or const automatically created in global scope ![](https://i.imgur.com/lOxRQFs.png) ![](https://i.imgur.com/9aAxfGU.png) ### Local Scope and Functions variables declared within function and function parameters have local scope. - only visible within that function ![](https://i.imgur.com/CH2mqPr.png) ![](https://i.imgur.com/INjNWjd.png) ![](https://i.imgur.com/lnMLdwl.png) ### Global vs. Local Scope in Functions ![](https://i.imgur.com/WS2nyDi.png) ![](https://i.imgur.com/wvx2DIT.png) ### Undefined Value Returned from a Function ![](https://i.imgur.com/Hiq5QgN.png) ![](https://i.imgur.com/jdXnvxZ.png) ### Assignment with a Returned Value ![](https://i.imgur.com/6ArwW7A.png) ![](https://i.imgur.com/RXphCpa.png) ### Stand in Line Challenge ![](https://i.imgur.com/unTy7Wt.png) ![](https://i.imgur.com/kqgGoUL.png) ### Boolean Values these may only be true or false in their value basically on off switches. true is on; false is off ![](https://i.imgur.com/rrPUyBN.png) ![](https://i.imgur.com/s7cutI6.png) ### Conditional Logic / If Statements ![](https://i.imgur.com/kbDYy8Z.png) ![](https://i.imgur.com/w1iZRnv.png) ![](https://i.imgur.com/fvpTUQD.png) ### Equality Operator ![](https://i.imgur.com/3rmRoKV.png) ![](https://i.imgur.com/XqwVwXC.png) ![](https://i.imgur.com/nwcF2jy.png) ### Strict Equality Operator ![](https://i.imgur.com/Obw06N2.png) ![](https://i.imgur.com/wACOSWH.png) ### Practice Value Comparison ![](https://i.imgur.com/Qtk6Njy.png) ![](https://i.imgur.com/vqEV3u7.png) ![](https://i.imgur.com/zFlrtAP.png) ### Comparison with Inequality Operator ![](https://i.imgur.com/d931KK3.png) ![](https://i.imgur.com/U1GT0zU.png) ### Strict Inequality Operator ![](https://i.imgur.com/OyjYhY3.png) ![](https://i.imgur.com/a6awCsl.png) ### Greater Than Operator ![](https://i.imgur.com/0I9DVaa.png) ![](https://i.imgur.com/BrW5d1E.png) ### Greater Than Or Equal To Operator ![](https://i.imgur.com/zqHQnOo.png) ![](https://i.imgur.com/RQ9SPHo.png) ### Less Than Opeartor ![](https://i.imgur.com/OuZS84h.png) ![](https://i.imgur.com/QjvuGhT.png) ### Less Than Or Equal To Operator ![](https://i.imgur.com/fvUo1dd.png) ![](https://i.imgur.com/M87H6Hk.png) ### Comparisons with the Logical And Operator ![](https://i.imgur.com/uniogD5.png) ![](https://i.imgur.com/jK90kM3.png) ![](https://i.imgur.com/ONSRrTi.png) ### Comparisons with the Logical Or Operator ![](https://i.imgur.com/n8f80kK.png) ![](https://i.imgur.com/aNWzmnG.png) ![](https://i.imgur.com/6aZpQsk.png) ### Else Statements ![](https://i.imgur.com/fKJ8TOV.png) ![](https://i.imgur.com/LqejtMX.png) ### Else If Statements ![](https://i.imgur.com/85MY8cx.png) ![](https://i.imgur.com/R8jTq0y.png) ### Logical Order in If Else Statements ![](https://i.imgur.com/xUKGReu.png) ![](https://i.imgur.com/AoGlKMA.png) ![](https://i.imgur.com/gEbdY3f.png) ### Chaining If Else Statements ![](https://i.imgur.com/Zlqw1MV.png) ![](https://i.imgur.com/6dUVwpN.png) ### Golf Game Challenge ![](https://i.imgur.com/3wgPk82.png) ![](https://i.imgur.com/esJCiIM.png) ### Selecting from Many Options with Switch Statements ![](https://i.imgur.com/09Cm5QC.png) ![](https://i.imgur.com/8mpfNid.png) ### Adding a Default Option in Switch Statements ![](https://i.imgur.com/pYSLVDK.png) ![](https://i.imgur.com/IRV7V8q.png) ![](https://i.imgur.com/rNEZ769.png) ### Multiple Identical Options in Switch Statements ![](https://i.imgur.com/Kr7PHxv.png) ![](https://i.imgur.com/DvHnxYU.png) ![](https://i.imgur.com/gnXQV28.png) ### Replaccing If Else Chains with Switch ![](https://i.imgur.com/sJw708Y.png) ![](https://i.imgur.com/XTXAzzS.png) ![](https://i.imgur.com/d4Vhl9r.png) ![](https://i.imgur.com/52GX4iK.png) ![](https://i.imgur.com/0SEO2Mx.png) ### Returning Boolean Values from Functions ![](https://i.imgur.com/bmrM71m.png) ![](https://i.imgur.com/Yj8GCnC.png) ### Return Early Pattern for Functions ![](https://i.imgur.com/uKp7YII.png) ![](https://i.imgur.com/o5eBISn.png) ![](https://i.imgur.com/j5y2bge.png) ### Counting Cards Challenge ![](https://i.imgur.com/mmDCmpB.png) ![](https://i.imgur.com/DEd2ZT8.png) ![](https://i.imgur.com/d12fSo6.png) ### JavaScript Objects ![](https://i.imgur.com/CwO2kMO.png) ![](https://i.imgur.com/2EP1a6O.png) ![](https://i.imgur.com/agsqvJC.png) ### Accessing Object Properties with Dot Notation ![](https://i.imgur.com/oB9vcJC.png) ![](https://i.imgur.com/ejz1V2L.png) ![](https://i.imgur.com/ECYsRFV.png) ### Accessing Object Properties with Bracket Notation ![](https://i.imgur.com/aHOksUL.png) ![](https://i.imgur.com/JRvQHD3.png) ![](https://i.imgur.com/JbvrTlR.png) ### Accessing Object Properties with Variables ![](https://i.imgur.com/Lv1lgmh.png) ![](https://i.imgur.com/PO5OBSX.png) ### Updating Object Properties ![](https://i.imgur.com/0cwzh7Z.png) ![](https://i.imgur.com/iVj0R3b.png) ### Add New Properties to a JavaScript Object ![](https://i.imgur.com/q9Ev0Dg.png) ![](https://i.imgur.com/wo1opiL.png) ![](https://i.imgur.com/wniQEVB.png) ### Delete Properties from JS Objects ![](https://i.imgur.com/2VrYYFw.png) ![](https://i.imgur.com/TfT0FFY.png) ![](https://i.imgur.com/HhRtV5K.png) ### Using Objects for Lookups ![](https://i.imgur.com/3kUwJUb.png) ![](https://i.imgur.com/KixxiSB.png) ![](https://i.imgur.com/oS1bgFJ.png) ![](https://i.imgur.com/zGkTWDq.png) ### Testing Objects for Properties ![](https://i.imgur.com/DYeyHEl.png) ![](https://i.imgur.com/J0eqwAq.png) ### Manipulating Complex Objects ![](https://i.imgur.com/GmUF705.png) ![](https://i.imgur.com/TABK2zM.png) ![](https://i.imgur.com/76XBuWH.png) ![](https://i.imgur.com/q4FR8rd.png) ### Accessing Nested Objects ![](https://i.imgur.com/EqeQEjZ.png) ![](https://i.imgur.com/FCfWU6C.png) ![](https://i.imgur.com/szLuy1p.png) ### Acessing Nest Arrays ![](https://i.imgur.com/GACbR2S.png) ![](https://i.imgur.com/eN6WD56.png) ![](https://i.imgur.com/6MuqjqK.png) ![](https://i.imgur.com/glhkjeG.png) ### Record Collection Challenge ![](https://i.imgur.com/nOLTjCM.png) ![](https://i.imgur.com/cCOjg4k.png) - I had to cheat on this to pass challenge and have no idea wtf this means >.< ### Iterate with JavaScript While Loops ![](https://i.imgur.com/XuqUXkn.png) "While loops" run when specified condition is true and stop when that condition is no longer true

    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
    Sign in via Google Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    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