Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save aviwarner/67811a90a3ff96e741fbe9586a248a0d to your computer and use it in GitHub Desktop.
Save aviwarner/67811a90a3ff96e741fbe9586a248a0d to your computer and use it in GitHub Desktop.
Bloc practice assessment for Module 2: Frontend Formations

Instructions

  1. Fork this Gist
  2. Edit to add your answers
  3. Send to your mentor

No cheating! Be open and honest about what you know.

Practice Questions

  1. Which HTML 5 tag would you use to semantically wrap your page navigation?
    Answer: <nav>

  2. What is the difference between a block level and an inline element in HTML?
    Answer: block level elements start on a new line take up the entire screen width, while inline elements can exist on the same line as other elements and will take up as much room as they are able to.

  3. What is wrong in the following HTML?

    <div class="someClass" id="someID">
      Check this out!
    </div>
    <div class="someClass" id="someID">
      No, look at this instead.
    </div>

    Answer: You shouldn't use the same 'id' twice.

  4. How would you create a new folder named testFolder with the command line?
    Answer: mkdir testFolder

  5. How would you enter this folder?
    Answer: cd testFolder

  6. Given you are now in this folder, how would you check if git has already been initialized in that folder?
    Answer: git status

  7. If git has not yet been added to that folder, how would you add it?
    Answer: git init

  8. Which industry vertical are you interested in and why?
    Answer: I'm really interested in B2Bs that function like B2Cs. Examples: Slack, Expensify, Collective Health (which happens to be my new employer). I like that combination of building an enterprise-grade product, but the high level of engagement with large numbers of users that might interact with the company directly.

  9. Using Javascript, please write a function foo, that takes two arguments, an array and a number, and returns true if the length of the array is equal to the second argument? E.g. foo([1, 2, 3], 3) would return true.
    Answer:

    // your code here
    function foo(array, number) {
     if (array.length === number) {
      return true; 
     } else {
      return false;
     }
    }
    foo([1, 2, 3], 3);
  10. Write a loop in Javascript, iterating over the array [1, 2, 3, 4] printing out if the element is either the first element (print first - ), the last element (print last) or neither first or last element (print not first or last -). E.g. the expected output would be (first - not first or last - not first or last - last).
    Answer:

    // your code here
    var printout = '';
     function arrayPrintout(array) {
      for (i = 0; i < array.length; i++) {
       if (i === 0) {
        printout += 'first - ';
       } else if (i != array.length - 1) {
        printout += 'not first or last - ';
       } else {
        printout += 'last';
       }
      }
     }
     arrayPrintout([1,2,3,4]);
     console.log(printout);
  11. Print all numbers from 15 - 0 to the console using a for loop in JS.
    Answer:

    // your code here
    var number = 15;
    while (number > -1) {
     console.log(number);
     number--;
    }
  12. What would the console print in following example

    function outer(input) {
      var a = input;
      
      function inner(multiplier) {
        console.log(a * multiplier);
      }
      
      return inner;
    }
    
    var firstResult = outer(9);
    firstResult(10);

    Answer: I'm unclear here how multiplier is being defined. I would think that var firstResult = outer(9); would return an error, since you're multiplying 9 by 'multiplier'. As this isn't correct (the code looks like it is meant to return 90, I need to do some digging here.

  13. Add the missing code to print "this is A" to the console by accessing the property from the JS object literal.

    var someObject = {b : "some test", a : "this is A"};
    console.log("*Your code here*");

    Answer:

    // your code here
    var someObject = {b : "some test", a : "this is A"};
    console.log(someObject.a);
@aviwarner
Copy link
Author

@mnichols thanks for sharing this. Most of this seemed pretty familiar to me, but I definitely had trouble with question 12. I'm going to spend some time figuring out why that works the way it does (specifically how outer and inner work in this code).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment