This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 1.) Make Student Reports | |
| function makeStudentsReport(data) { | |
| const results = []; | |
| for (let i = 0; i < data.length; i++) { | |
| const item = data[i]; | |
| results.push(`${item.name}: ${item.grade}`); | |
| } | |
| return results; | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 1.) Object creator drill | |
| function createMyObject() { | |
| return { | |
| foo: "bar", | |
| answerToUniverse: 42, | |
| "olly olly": "oxen free", | |
| sayHello: function() { | |
| return "hello"; | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 1.) What is scope? Your explanation should include the idea of global vs. local scope. | |
| Scope is the extent of the area in the code where a piece of code can behave or be accessed. How the code is executed depends on where the variables are defined within the scope chain. Global scope is when a variable is defined outside of a function. This means it can be used anywhere in the code, therefore it is global. Local scope is when a variable is defined inside of the function, and can therefore only be executed within that code's block of instructions. Outside of the function it is defined inside, it ceases to exist, and the code will try to access variables in the parent code, and eventaully the global scope. | |
| 2.) Why are global variables avoided? | |
| Global variables can be accessed anywhere in the code and even across files, but they can also be altered in unintended ways. If the code has undefined variables, for instance, it will search through the scope chain until it finds a variable to use, and sicne the glo | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function fizzBuzz(countTo) { | |
| const result = []; | |
| for (let i = 1; i<=countTo; i++) { | |
| if (i % 15 === 0) { | |
| result.push("fizzbuzz"); | |
| } else if (i % 5 === 0) { | |
| result.push("buzz"); | |
| } else if (i % 3 === 0) { | |
| result.push("fizz"); | |
| } else { | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function average(numbers) { | |
| let total = numbers[0]; | |
| for (let i = 1; i < numbers.length; i++) { | |
| total += numbers[i]; | |
| } | |
| return total / numbers.length; | |
| } | |
| /* From here down, you are not expected to | |
| understand.... for now :) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function max(numbers) { | |
| let currentMax = numbers[0]; | |
| for (let i = 0; i < numbers.length; i++) { | |
| if (numbers[i] > currentMax) { | |
| currentMax = numbers[i]; | |
| } | |
| } | |
| return currentMax; | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function divisibleBy5(array) { | |
| return array.find(function(num) { | |
| return num % 5 === 0; | |
| }); | |
| } | |
| /* From here down, you are not expected to | |
| understand.... for now :) | |
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function greatestToLeast(array) { | |
| return array.sort(function(a, b) {return b-a; | |
| }); | |
| } | |
| /* From here down, you are not expected to | |
| understand.... for now :) | |
| Nothing to see here! | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function minusLastItem(array) { | |
| return array.slice(0, array.length-1); | |
| } | |
| function copyFirstHalf(array) { | |
| return array.slice(0, array.length / 2); | |
| } | |
| /* From here down, you are not expected to | |
| understand.... for now :) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function firstFourItems(array) { | |
| return array.slice(0, 4); | |
| } | |
| function lastThreeItems(array) { | |
| return array.slice(-3); | |
| } | |
| /* From here down, you are not expected to | |
| understand.... for now :) |