JavaScript Language

Sprint 6.5

19 September 2018

  1. Explain all the use cases for parentheses ()
    1. Execute a function eg. var result = doSomething()
    2. Define a loop eg. for (i=0;...)
    3. Grouping expressions eg. (2+2) * 4

  2. Explain all the use cases for brackets []
    1. Containing arrays eg. car: [wheels, body, engine]
    2. Accessing an element eg. car[0] will return "wheels" or car[i] if accessing variable from a loop

  3. Explain all the use cases for braces {}
    1. To declare an object eg. var car = {}
    2. To enclose code eg. when creating a loop or function: function myFunction () {what function does here}

  4. Explain all the use cases for single quotes ' '
    1. To define a string eg 'spaghetti'
    2. If there are double quotes within the string you are defining it is best to use single quotes around the string eg. 'Harry said, "Go home" '

  5. Explain all the use cases for double quotes " "
    1. To define a string eg "spaghetti"
    2. If there is a single quote within the string you want to define, it is best to use double quotes to define the string eg "This isn't going to affect the string"