Giter Club home page Giter Club logo

w2-quiz's Introduction

ga logo

wdi-cc


Title: Combining data types/Callbacks
Type: Quiz/In-class assignment
Creator: Matt Huntington
Adapted by: Reuben Ayres
Competencies: Objects, Arrays, Loops
Prerequisites: JavaScript


Setup

  1. IMPORTANT: Read all instructions on this quiz very carefully before you do them!
  2. Create a quiz folder in today's folder, and inside of that folder do you know what.
  3. Copy the questions that you are answering into your file (and comment it out) and write the answer below the question.

Combine objects, arrays, and functions

COMPLETE ANY 3

  1. Create an object that has a property that is an array. Log one of the elements of that array.
  2. Create an object that has a property that is an object. Log one of the properties of that inner object.
  3. Create an object that has a property that is a function (method). Call that method.
  4. Create an array that has an object in it. Log one of the properties of that object.
  5. Create an array that has an array as one of its elements. Log one of the elements of the inner array.
  6. Create an array that has a function as one of its elements. Call that function.
  7. Create an object that has a property that is an array. Loop over the array and log each individual element.
  8. Create an array that has an array as one of its elements. Loop over the second array and log each individual element.
    • Bonus: make each element of the outer array an array as well. Using two for loops, loop over each array in the outer array and log those elements.

Commit 1


๐Ÿ”ด The commit message should read:
"Commit 1 - Combine objects, arrays, and functions"

Combine objects, arrays, and functions more than one level deep

COMPLETE ANY 3

  1. Create a function that returns an object. Log a property of that object (hint: call the function and then call a property on the return value).
  2. Create a function that returns an array. Log an element of the array.
  3. Create a function that returns an object that has an array. Log one of the elements of that array.
  4. Create a function that returns an object that has an object. Log one of the properties of the inner object.
  5. Create a function that returns an object that has a method. Call that inner function (method).
  6. Create a function that returns a function. Call that inner function
  7. Create an object that has a method that returns an object. Log a property of the inner object.
  8. Create an object that has a method that returns an object that has an array. Log an element of that array.
  9. Create an object that has a method that returns an object that has an object. Log a property of the inner object.
  10. Create an object that has a method that returns an object that has another method. Call the inner method.
  11. Create an object that has a method that returns a function. Call that function.
  12. Create an array that has a function that returns an object. Log a property of the object.
  13. Create an array that has a function that returns an object that has an array. Log an element of the inner array.
  14. Create an array that has a function that returns an object that has an object. Log a property of the inner object.
  15. Create an array that has a function that returns an object that has a method. Call that method.
  16. Create an array that has a function that returns a function. Call the inner function.

Commit 2


๐Ÿ”ด The commit message should read:
"Commit 2 - Combine objects, arrays, and functions more than one level deep"

Create a callback

  1. Define two functions and set them to variables
  2. The second function takes a parameter
  3. Call the second function, passing in the variable that references the first function as the parameter
  4. In the definition of the second function, invoke (call) the parameter that is being passed into it. Remember, this parameter is a function

Commit 3


๐Ÿ”ด The commit message should read:
"Commit 3 - Create a callback"

Indentation

Correctly indent the following code:

            if(true){
    const a = 2 + 2;
console.log(a);
        }

    if(true){
if(false){
            console.log('hi');
    }
                }

Commit 4


๐Ÿ”ด The commit message should read:
"Commit 4 - Indentation"

Semantic naming of variables

Fix this variable to have a better name:

const c = [2, 4, 6, 8, 10];

Commit 5


๐Ÿ”ด The commit message should read:
"Commit 5 - Semantic naming of variables"

Function definition placement

Clean up this code, so that it works and has function definitions in the correct place

bar();
const bar = ()=>{
    console.log('bar here');
}
foo();

const foo = ()=>{
    console.log('foo here');
}

Commit 6


๐Ÿ”ด The commit message should read:
"Commit 6 - Function definition placement"

Commenting code

Write your own comments for each line of code:

const addTwoNums = (firstNum, secondNum)=>{
    const finalValue = firstNum + secondNum;
    return finalValue;
}

Commit 7


๐Ÿ”ด The commit message should read:
"Commit 7 - Commenting code"

Describe some common programming principles

Read this article (don't worry it's short): http://www.artima.com/weblogs/viewpost.jsp?thread=331531

Error reading

What is meant by the error this produces?

foo();

const foo ()=>{
    console.log('hi');
}

Commit 8


๐Ÿ”ด The commit message should read:
"Commit 8 - Error reading"

Coerce data types

Fix the following code so the log executes (don't change the if statement):

const b = '5';

if(b === 5){ //will be false
    console.log('this line should execute');
}

Fix the following code so the value 10 is logged (change only the line that has the console.log on it):

const a = '5';
console.log(5 + a);

Commit 9


๐Ÿ”ด The commit message should read:
"Commit 9 - Coerce data types"

w2-quiz's People

Contributors

reubenayres avatar

Watchers

Kenneth Bushman avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.