Guest User

Untitled

a guest
May 27th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.49 KB | None | 0 0
  1. # Instructions
  2.  
  3. 1. Fork this Gist
  4. 2. Edit to add your answers
  5. 3. Send to your mentor
  6.  
  7. No cheating! Be open and honest about what you know.
  8.  
  9. # Practice Questions
  10.  
  11. 1. Which HTML 5 tag would you use to semantically wrap your page navigation?
  12. **Answer:**
  13. `<nav>` tag
  14.  
  15. 2. What is the difference between a block level and an inline element in HTML?
  16. **Answer:**
  17. Block level takes up entire line whereas inline elements can be on one line.
  18.  
  19. 3. What is wrong in the following HTML?
  20. ```html
  21. <div class="someClass" id="someID">
  22. Check this out!
  23. </div>
  24. <div class="someClass" id="someID">
  25. No, look at this instead.
  26. </div>
  27. ```
  28. **Answer:**
  29. id attributes are required to be unique.
  30.  
  31. 4. How would you create a new folder named `testFolder` with the command line?
  32. **Answer:**
  33. `mkdir testFolder`
  34.  
  35. 5. How would you enter this folder?
  36. **Answer:**
  37. `cd testFolder`
  38.  
  39. 6. Given you are now in this folder, how would you check if git has already been initialized in that folder?
  40. **Answer:**
  41. `git status`
  42.  
  43. 7. If git has not yet been added to that folder, how would you add it?
  44. **Answer:**
  45. `git init`
  46.  
  47. 8. Which industry vertical are you interested in and why?
  48. **Answer:**
  49. Pretty open, but ecommerce and fintech are industries I've had previous experience in.
  50.  
  51. 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.
  52. **Answer:**
  53. ```javascript
  54. function foo(x, y) {
  55. if (x.length == y) {
  56. return true;
  57. }
  58. else {
  59. return "Array length is not equal to " + y
  60. }
  61. };
  62.  
  63. foo([1, 2, 3], 3);
  64.  
  65. ```
  66.  
  67. 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`).
  68. **Answer:**
  69. ```javascript
  70. function loop(n) {
  71. for (i = 0; i < n.length; i++) {
  72. //first element
  73. if (i === 0) {
  74. console.log('first - ');
  75. }
  76. //last element
  77. else if (i === (n.length - 1)) {
  78. console.log('last');
  79. }
  80. //neither first or last element
  81. else {
  82. console.log('not first or last -');
  83. }
  84. }
  85. };
  86.  
  87. var test = [1, 2, 3, 4, 5]
  88. loop(test);
  89.  
  90. ```
  91.  
  92. 11. Print all numbers from 15 - 0 to the console using a for loop in JS.
  93. **Answer:**
  94. ```javascript
  95. function printNum() {
  96. for (n = 15; n >= 0; n--) {
  97. console.log(n);
  98. }
  99. };
  100.  
  101. printNum();
  102.  
  103. ```
  104.  
  105. 12. What would the console print in following example
  106. ```javascript
  107. function outer(input) {
  108. var a = input;
  109.  
  110. function inner(multiplier) {
  111. console.log(a * multiplier);
  112. }
  113.  
  114. return inner;
  115. }
  116.  
  117. var firstResult = outer(9);
  118. firstResult(10);
  119. ```
  120.  
  121. **Answer:**
  122. It would print 90.
  123.  
  124. 13. Add the missing code to print "this is A" to the console by accessing the property from the JS object literal.
  125. ```javascript
  126. var someObject = {b : "some test", a : "this is A"};
  127. console.log("*Your code here*");
  128. ```
  129.  
  130. **Answer:**
  131. ```javascript
  132. var someObject = {b : "some test", a : "this is A"};
  133. console.log(someObject.a);
  134.  
  135. ```
Add Comment
Please, Sign In to add comment