Introduction to JavaScript

Casts go along with curriculum at freecodecamp.org.
    var number = 5; // in-line comment
    
    /* this is a
    d
    d
    d
    sdfas
    
    dsaf
    vczx
    
    
    multi-line comment */
    
    /* Data Types:
    undefined, null, boolean, string, symbol, number, and object
    */
    
    var myName = "Beau"
    
    myNa
    var a;
    var b = 2;
    
    a = 7;
    
    b = a
    
    // Initialize these three variables
    var a;
    var b;
    var c;
    
    // Do not change code below this line
    
    a = a + 1;
    b = b + 5;
    c = c + " String!";
    // Declarations
    var studlyCapVar;
    var properCamelCase;
    var titleCaseOver;
    
    // Assignments
    studlyCapVar = 10;
    properCamelCase = "A String";
    titleCaseOver = 9000;
    var sum = 10 + 10;
    console.log(sum)
    var difference = 45 - 0;
    var product = 8 * 0;
    var quotient = 66 / 33;
    var myVar = 87;
    
    // Only change code below this line
    myVar = myVar + 1;
    var myVar = 11;
    
    // Only change code below this line
    myVar--;
    
    var ourDecimal = 5.7;
    
    // Only change code below this line
    
    var myDecimal = 0.009
    var product = 2.0 * 0.0;
    var quotient = 0.0 / 2.0; // Fix this line
    
    
    // Only change code below this line
    
    var remainder;
    remainder = 11 % 3;
    var a = 3;
    var b = 17;
    var c = 12;
    
    // Only modify code below this line
    
    a += 12;
    b +=
    c = c + 7;
    
    var a = 11;
    var b = 9;
    var c = 3;
    
    // Only modify code below this line
    
    a -= 6;
    b = b - 15;
    c = c - 1;
    
    var a = 5;
    var b = 12;
    var c = 4.6;
    
    // Only modify code below this line
    
    a = a * 5;
    b = 3 * b;
    c = c * 10;
    var a = 48;
    var b = 108;
    var c = 33;
    
    // Only modify code below this line
    
    a /= 12;
    b /= 4;
    c /= 11;
    var a = 48;
    var b = 108;
    var c = 33;
    
    // Only modify code below this line
    
    a /= 12;
    b /= 4;
    c /= 11;
    var myStr = "I am a \"double quoted\" string inside \"double quotes\".";
    console.log(myStr)
    var myStr = "I am a \"double quoted\" string inside \"double quotes\".";
    console.log(myStr)
    /*****
    CODE  OUTPUT
    \'	  single quote
    \"	  double quote
    \\	  backslash
    \n	  newline
    \r	  carriage return
    \t	  tab
    \b	  backspace
    \f	  form feed
    *****/
    
    var myStr = "FirstLine\n\t\\SecondLine\nThirdLine"
    // Example
    var ourStr = "I come first. " + "I come second.";
    
    // Only change code below this line
    
    var myStr = "This is the start. " + "This is the end."
    console.log(myStr);
    
    
    // Example
    var ourStr = "I come first. ";
    ourStr += "I come second.";
    
    // Only change code below this line
    
    var myStr = "This is the first"
    
    
    // Example
    var ourName = "freeCodeCamp";
    var ourStr = "Hello, our name is " + ourName + ", how are you?";
    
    // Only change code below this line
    var myName = "Beau";
    var myStr = "My name is " + myName + " and I am well!";
    console.log(myStr)
    // Example
    var anAdjective = "awesome!";
    var ourStr = "freeCodeCamp is ";
    ourStr += anAdjective;
    
    // Only change code below this line
    
    var someAdjective;
    var myStr = "Learning to code is ";
    // Example
    var firstNameLength = 0;
    var firstName = "Ada";
    
    firstNameLength = firstName.length;
    
    // Setup
    var lastNameLength = 0;
    var lastName = "Lovelace";
    
    // Only change code below this line.
    
    lastNameLength = lastName.length;
    console.log(lastNameLength)
    // Example
    var firstLetterOfFirstName = "";
    var firstName = "Ada";
    
    firstLetterOfFirstName = firstName[0];
    
    // Setup
    var firstLetterOfLastName = "";
    var lastName = "Lovelace";
    
    // Only change code below this line
    firstLetterOfLastName = lastName[0];
    console.log(firstLetterOfLastName)
    
    // Setup
    var myStr = "Jello World";
    
    // Only change code below this line
    
    myStr[0] = "H"; // Fix Me
    
    
    // Example
    var firstName = "Ada";
    var secondLetterOfFirstName = firstName[1];
    
    // Setup
    var lastName = "Lovelace";
    
    // Only change code below this line.
    var thirdLetterOfLastName = lastName;
    
    
    // Example
    var firstName = "Ada";
    var lastLetterOfFirstName = firstName[firstName.length - 1];
    
    // Setup
    var lastName = "Lovelace";
    
    // Only change code below this line.
    var lastLetterOfLastName = lastName;
    
    
    // Example
    var firstName = "Ada";
    var lastLetterOfFirstName = firstName[firstName.length - 1];
    
    // Setup
    var lastName = "Lovelace";
    
    // Only change code below this line.
    var lastLetterOfLastName = lastName[lastName.length - 1];
    
    
    function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
      // Your code below this line
      var result = "";
      result += "The " + myAdjective + myNoun + myVerb + " to the store " + myAdverb + ".";
      // Your code above this line
      return result;
    }
    
    // Change the words here to test your function
    console.log(wordBlanks("dog", "big", "ran", "quickly"));
    
freeCodeCamp4:137 months ago
    // Example
    var ourArray = ["John", 23];
    
    // Only change code below this line.
    var myArray = [];
    
    // Example
    var ourArray = [["the universe", 42], ["everything", 101010]];
    
    // Only change code below this line.
    var myArray = [];
    // Example
    var ourArray = [50,60,70];
    var ourData = ourArray[0]; // equals 50
    
    // Setup
    var myArray = [50,60,70];
    
    // Only change code below this line.
    
    // Example
    var ourArray = [18,64,99];
    ourArray[1] = 45; // ourArray now equals [18,45,99].
    
    // Setup
    var myArray = [18,64,99];
    
    // Only change code below this line.
    myArray[0] = 45;
    console.log(myArray)
    // Setup
    var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];
    
    // Only change code below this line.
    var myData = myArray[2][1];
    console.log(myData);
    // Example
    var ourArray = ["Stimpson", "J", "cat"];
    ourArray.push(["happy", "joy"]); 
    // ourArray now equals ["Stimpson", "J", "cat", ["happy", "joy"]]
    
    // Setup
    var myArray = [["John", 23], ["cat", 2]];
    
    // Only change code below this line.
    
    
    // Example
    var ourArray = [1,2,3];
    var removedFromOurArray = ourArray.pop(); 
    // removedFromOurArray now equals 3, and ourArray now equals [1,2]
    
    // Setup
    var myArray = [["John", 23], ["cat", 2]];
    
    // Only change code below this line.
    var removedFromMyArray;
    
    
    // Example
    var ourArray = ["Stimpson", "J", ["cat"]];
    var removedFromOurArray = ourArray.shift();
    // removedFromOurArray now equals "Stimpson" and ourArray now equals
    
    // Setup
    var myArray = [["John", 23], ["dog", 3]];
    
    // Only change code below this line.
    var removedFromMyArray = myArray.shift();
    // Example
    var ourArray = ["Stimpson", "J", "cat"];
    ourArray.shift(); // ourArray now equals ["J", "cat"]
    ourArray.unshift("Happy"); 
    // ourArray now equals ["Happy", "J", "cat"]
    
    // Setup
    var myArray = [["John", 23], ["dog", 3]];
    myArray.shift();
    
    // Only change code below this line.
    
    
    var myList = [["cereal", 3], ["milk", 2], ["bananas", 3], ["juice", 2], ["eggs", 12]];
    // Example
    function ourReusableFunction() {
      console.log("Heyya, World");
    }
    
    ourReusableFunction();
    
    // Only change code below this line
    // Example
    function ourFunctionWithArgs(a, b) {
      console.log(a - b);
    }
    ourFunctionWithArgs(10, 5); // Outputs 5
    
    // Only change code below this line.
    
    function functionWithArgs(a, b) {
      console.log(a + b);
    }
    
    functionWi
    // Declare your variable here
    var myGlobal = 10;
    
    function fun1() {
      // Assign 5 to oopsGlobal Here
      oopsGlobal = 5;
    }
    
    // Only change code above this line
    function fun2() {
      var output = "";
      if (typeof myGlobal != "undefined") {
        output += "myGlobal: " + myGlobal;
      }
    function myLocalScope() {
      var myVar = 5;
      console.log(myVar);
    }
    myLocalScope();
    
    console.log(myVar);
    
    var outerWear = "T-Shirt";
    
    function myOutfit() {
      var outer
    
      return outerWear;
    }
    
    console.log(myOutfit());
    function minusSeven(num) {
      return num - 7;
    }
    
    console.log(minusSeven(10));
    
    function timesFive(num) {
      return num * 5;
    }
    
    console.log(timesFive(5));
    // Example
    var sum = 0;
    function addThree() {
      sum = sum + 3;
    }
    
    function addFive() {
      sum += 5;
    }
    var changed = 0;
    
    function change(num) {
      return (num + 5) / 3;
    }
    
    changed = change(10);
    
    
    var processed = 0;
    
    function processArg(num) {
      return (num + 3) / 5;
    }
    function nextInLine(arr, item) {
      // Your code here
      arr.
      return item; 
    }
    
    var testArr = [1,2,3,4,5];
    
    console.log("Before: " + JSON.stringify(testArr));
    console.log(nextInLine(testArr, 6));
    console.log("After: " + JSON.stringify(testArr));
    function welcomeToBooleans() {
      return true;
    }
    // Example
    function ourTrueOrFalse(isItTrue) {
      if (isItTrue) { 
        return "Yes, it's true";
      }
      return "No, it's false";
    }
    
    function trueOrFalse(wasThatTrue) {
      if (wasThatTrue) {
        return "Yes, that was true";
      }
      return "No, that was false";
    
    // Setup
    function testEqual(val) {
      if (val == 12) { // Change this line
        return "Equal";
      }
      return "Not Equal";
    }
    
    // Change this value to test
    console.log(testEqual(10));
    // Setup
    function testStrict(val) {
      if (val) { // Change this line
        return "Equal";
      }
      return "Not Equal";
    }
    
    // Change this value to test
    testStrict(10);
    
    /*
    3 == 3 
    3 == '3' 
    // Setup
    function compareEquality(a, b) {
      if (a == b) { // Change this line
        return "Equal";
      }
      return "Not Equal";
    }
    
    // Change this value to test
    console.log(compareEquality(10, "10"));
    // Setup
    function testNotEqual(val) {
      if (val) { // Change this line
        return "Not Equal";
      }
      return "Equal";
    }
    
    // Change this value to test
    console.log(testNotEqual(10));
    // Setup
    function testStrictNotEqual(val) {
      // Only Change Code Below this Line
      
      if (val !== 17) {
    
      // Only Change Code Above this Line
    
        return "Not Equal";
      }
      return "Equal";
    }
    
    // Change this value to test
    // Setup
    function testStrictNotEqual(val) {
      // Only Change Code Below this Line
      
      if (val) {
    
      // Only Change Code Above this Line
    
        return "Not Equal";
      }
      return "Equal";
    }
    
    // Change this value to test
    function testGreaterOrEqual(val) {
      if (val) {  // Change this line
        return "20 or Over";
      }
      
      if (val) {  // Change this line
        return "10 or Over";
      }
    
      return "Less than 10";
    }
    
    // Change this value to test
    console.log(testGreaterOrEqual(10));
    function testLessThan(val) {
      if (val) {  // Change this line
        return "Under 25";
      }
      
      if (val) {  // Change this line
        return "Under 55";
      }
    
      return "55 or Over";
    }
    
    // Change this value to test
    console.log(testLessThan(10));
    function testLessOrEqual(val) {
      if (val) {  // Change this line
        return "Smaller Than or Equal to 12";
      }
      
      if (val) {  // Change this line
        return "Smaller Than or Equal to 24";
      }
    
      return "More Than 24";
    }
    
    // Change this value to test
    console.log(testLessOrEqual(10));
    function testLogicalAnd(val) {
      // Only change code below this line
    
      if (val <= 50 && val >= 25) {
        return "Yes";
      }
    
      // Only change code above this line
      return "No";
    }
    
    // Change this value to test
    testLogicalAnd(10);
    function testLogicalOr(val) {
      // Only change code below this line
    
      if (val < 10 ) {
        return "Outside";
      }
    
      if (val > 20) {
        return "Outside";
      }
    
      // Only change code above this line
      return "Inside";
    }
    function testElse(val) {
      var result = "";
      // Only change code below this line
      
      if (val > 5) {
        result = "Bigger than 5";
      }
      
      if (val <= 5) {
        result = "5 or Smaller";
      }
      
      // Only change code above this line
      return result;
    function testElseIf(val) {
      if (val > 10) {
        return "Greater than 10";
      }
      
      if (val < 5) {
        return "Smaller than 5";
      }
      
      return "Between 5 and 10";
    }
    
    // Change this value to test
    testElseIf(7);
    function orderMyLogic(val) {
      if (val < 5) {
        return "Less than 5";
      } else if (val < 10) {
        return "Less than 10";
      } else {
        return "Greater than or equal to 10";
      }
    }
    
    // Change this value to test
    console.log(orderMyLogic(3));
    function testSize(num) {
      if (num < 5) {
        return "Tiny"
      } else if (num < 10) {
        return "Small"
      } else if (num < 15) {
        return "Medium"
      } else if (num < 20) {
        return "Large"
      } else {
        return "Huge"
      }
    }
    
    var names = ["Hole-in-one!", "Eagle", "Birdie", "Par", "Bogey", "Double Bogey", "Go Home!"];
    function golfScore(par, strokes) {
      if (strokes == 1) {
        return names[0]
      } else if (strokes <= par - 2) {
        return names[1]
      } else if (strokes == par - 1) {
        return names[2]
      } else if (strokes == par) {
        return names[3]
      } else if (strokes == par + 1) {
        return names[4]
      } else if (strokes == par + 2) {
        return names[5]
freeCodeCamp4:265 months ago
    function caseInSwitch(val) {
      var answer = "";
      switch(val) {
        case 1:
          answer = "alpha";
          break;
        case 2:
          answer = "beta";
          break;
        
      }
    
      return answer;  
    }
    function switchOfStuff(val) {
      var answer = "";
      switch (val) {
        case "a":
          answer = "apple";
          break;
        case "b":
          answer = "bird";
          break;
        case "c":
          answer = "cat";
          break;
        default:
          answer = "stuff";
    function sequentialSizes(val) {
      var answer = "";
      switch(val) {
        case 1:
        case 2:
        case 3:
          answer = "Low";
          break;
        case 4:
        case 5:
        case 6:
          answer = "Mid";
          break;
        case 7:
    function chainToSwitch(val) {
      var answer = "";
      // Only change code below this line
      
      switch(val) {
        case "bob":
          answer = "Marley";
          break;
        case 42:
          answer = "The Answer";
          break;
        case 1:
          answer = "There is no #1";
          break;
    function isLess(a, b) {
      // Fix this code
      return a < b;
    }
    
    // Change these values to test
    console.log(isLess(20, 15));
    // Setup
    function abTest(a, b) {
      // Only change code below this line
      
      if (a < 0 || b < 0) {
        return undefined;
      }
      
      
      // Only change code above this line
    
      return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
    }
    
    var count = 0;
    
    function cc(card) {
      switch(card) {
        case 2:
        case 3:
        case 4:
        case 5:
        case 6:
          count++;
          break;
        case 10:
        case "J":
        case "Q":
    // Example
    var ourDog = {
      "name": "Camper",
      "legs": 4,
      "tails": 1,
      "friends": ["everything!"]
    };
    
    // Only change code below this line.
    
    var myDog = {
      "name": "Quincy",
      "legs": 3,
      "tails": 2,
    // Setup
    var testObj = {
      "hat": "ballcap",
      "shirt": "jersey",
      "shoes": "cleats"
    };
    
    // Only change code below this line
    
    var hatValue = testObj.hat;      // Change this line
    var shirtValue = testObj.shirt;    // Change this line
    // Setup
    var testObj = {
      "an entree": "hamburger",
      "my side": "veggies",
      "the drink": "water"
    };
    
    // Only change code below this line
    
    var entreeValue = testObj["an entree"];   // Change this line
    var drinkValue = testObj['the dring'];    // Change this line
    // Setup
    var testObj = {
      12: "Namath",
      16: "Montana",
      19: "Unitas"
    };
    
    // Only change code below this line;
    
    var playerNumber = 16;       // Change this Line
    var player = testObj;   // Change this Line
    // Example
    var ourDog = {
      "name": "Camper",
      "legs": 4,
      "tails": 1,
      "friends": ["everything!"]
    };
    
    ourDog.name = "Happy Camper";
    
    // Setup
    var myDog = {
      "name": "Coder",
      "legs": 4,
    // Example
    var ourDog = {
      "name": "Camper",
      "legs": 4,
      "tails": 1,
      "friends": ["everything!"]
    };
    
    ourDog.name = "Happy Camper";
    
    // Setup
    var myDog = {
      "name": "Coder",
      "legs": 4,
    // Example
    var ourDog = {
      "name": "Camper",
      "legs": 4,
      "tails": 1,
      "friends": ["everything!"],
      "bark": "bow-wow"
    };
    
    delete ourDog.bark;
    
    // Setup
    var myDog = {
      "name": "Happy Coder",
    // Setup
    function phoneticLookup(val) {
      var result = "";
    
      // Only change code below this line
      
      var lookup = {
        "alpha": "Adams",
        "bravo": "Boston",
        "charlie": "Chicago",
        "delta": "Denver",
        "echo": "Easy",
        "foxtrot": "frank"
      };
    // Setup
    var myObj = {
      gift: "pony",
      pet: "kitten",
      bed: "sleigh"
    };
    
    function checkObj(checkProp) {
      // Your Code Here
      myObj.hasOwnProperty(checkProp)
      return "Change Me!";
    }
    
    // Test your code by modifying these values
    var myMusic = [
      {
        "artist": "Billy Joel",
        "title": "Piano Man",
        "release_year": 1973,
        "formats": [ 
          "CD",
          "8T",
          "LP"
        ],
        "gold": true
      }, 
      // Add record here
      {
    // Setup
    var myStorage = {
      "car": {
        "inside": {
          "glove box": "maps",
          "passenger seat": "crumbs"
         },
        "outside": {
          "trunk": "jack"
        }
      }
    };
    
    var gloveBoxContents = myStorage.car.inside["glove box"]; // Change this line
    // Setup
    var myPlants = [
      { 
        type: "flowers",
        list: [
          "rose",
          "tulip",
          "dandelion"
        ]
      },
      {
        type: "trees",
        list: [
          "fir",
    // Setup
    var collection = {
        "2548": {
          "album": "Slippery When Wet",
          "artist": "Bon Jovi",
          "tracks": [ 
            "Let It Rock", 
            "You Give Love a Bad Name" 
          ]
        },
        "2468": {
          "album": "1999",
          "artist": "Prince",
          "tracks": [ 
    var myArray = [];
    
    var i = 0;
    while(i < 5) {
      myArray.push(i);
      i++;
    }
    
    console.log(myArray);
    // Example
    var ourArray = [];
    
    for (var i = 0; i < 5; i++) {
      ourArray.push(i);
    }
    
    // Setup
    var myArray = [];
    
    // Only change code below this line.
    
    for (var i = 1; i < 6; i++) {
      myArray.push(i);
    // Example
    var ourArray = [];
    
    for (var i = 0; i < 10; i += 2) {
      ourArray.push(i);
    }
    
    console.log(ourArray);
    
    // Setup
    var myArray = [];
    
    // Only change code below this line.
    
    // Example
    var ourArray = [];
    
    for (var i = 10; i > 0; i -= 2) {
      ourArray.push(i);
    }
    
    console.log(ourArray);
    
    // Setup
    var myArray = [];
    
    // Only change code below this line.
    
    // Example
    var ourArr = [ 9, 10, 11, 12];
    var ourTotal = 0;
    
    for (var i = 0; i < ourArr.length; i++) {
      ourTotal += ourArr[i];
    }
    
    console.log(ourTotal);
    
    // Setup
    var myArr = [ 2, 3, 4, 5, 6];
    var total = 0;
    
    function multiplyAll(arr) {
      var product = 1;
      
      for (var i = 0; i < arr.length; i++) {
        for (var j = 0; i < arr[i].length; j++) {
          product *= arr[i][j]
        }
      }
    
      return product;
    }
    
    
    var product = multiplyAll([[1,2],[3,4],[5,6,7]]);
    function multiplyAll(arr) {
      var product = 1;
      
      for (var i=0; i < arr.length; i++) {
        for (var j=0; j < arr[i].length; j++) {
          product *= arr[i][j];
        }
      }
    
      return product;
    }
    
    var product = multiplyAll([[1,2],[3,4],[5,6,7]]);
    
    // Setup
    var myArray = [];
    var i = 10;
    
    // Only change code below this line.
    
    while (i < 5) {
      myArray.push(i);
      i++;
    }
    
    console.log(i, myArray);
    //Setup
    var contacts = [
        {
            "firstName": "Akira",
            "lastName": "Laine",
            "number": "0543236543",
            "likes": ["Pizza", "Coding", "Brownie Points"]
        },
        {
            "firstName": "Harry",
            "lastName": "Potter",
            "number": "0994372684",
            "likes": ["Hogwarts", "Magic", "Hagrid"]
        },
    function randomFraction() {
    
    
      return 0;
    }
    
    console.log(randomFraction());
    var randomNumberBetween0and19 = Math.floor(Math.random() * 20);
    
    function randomWholeNum() {
    
    
      return Math.floorMath.random();
    }
    
    console.log(randomWholeNum());
    // Example
    function ourRandomRange(ourMin, ourMax) {
    
      return Math.floor(Math.random() * (ourMax - ourMin + 1)) + ourMin;
    }
    
    ourRandomRange(1, 9);
    
    // Only change code below this line.
    
    function randomRange(myMin, myMax) {
    
      return 0; 
    
    function convertToInteger(str) {
      ret
    }
    
    convertToInteger("56");
    function convertToInteger(str) {
      r
    }
    
    convertToInteger("10011");
    // condition ? statement-if-true : statement-if-false;
    
    function checkEqual(a, b) {
      return a === b ? true : false;
      
      fe
    }
    
    checkEqual(1, 2);
    function checkSign(num) {
      return num > 0 ? "positive" : num < 0 ? "negative" : "zero"
    }
    
    console.log(checkSign(10));
    let catName = "Quincy";
    let quote;
    
    catName = "Beau";
    
    function catTalk() {
      "use strict";
    
      catName = "Oliver";
      quote = catName + " says Meow!";
    
    }
    catTalk();
    function checkScope() {
    "use strict";
      //let i = "function scope";
      if (true) {
        let i = "block scope";
        console.log("Block scope i is: ", i);
      }
      console.log("Function scope i is: ", i);
      return i;
    }
    
    checkScope();
    function printManyTimes(str) {
      "use strict";
    
      const SENTENCE = str + " is cool!";
      
      for(let i = 0; i < str.length; i+=2) {
        console.log(SENTENCE);
      }
    
    }
    printManyTimes("freeCodeCamp");
    const s = [5, 7, 2];
    function editInPlace() {
      "use strict";
    
      //s = [2, 5, 7];
      s[0] = 2;
      s[1] = 5;
      s[2] = 7;
    
    }
    editInPlace();
    
    console.log(s)
    function freezeObj() {
      "use strict";
      const MATH_CONSTANTS = {
        PI: 3.14
      };
      
      Object.freeze(MATH_CONSTANTS);
    
      try {
        MATH_CONSTANTS.PI = 99;
      } catch( ex ) {
        console.log(ex);
      }
      return MATH_CONSTANTS.PI;
    const magic = () => new Date();
    const myConcat = (arr1, arr2) => arr1.concat(arr2);
    
    console.log(myConcat([1, 2], [3, 4, 5]));
    const realNumberArray = [4, 5.6, -9.8, 3.14, 42, 6, 8.34, -2];
    
    const squareList = (arr) => {
      const squaredIntegers = arr.filter(num => Number.isInteger(num) && num > 0).map(x =>;
      return squaredIntegers;
    };
    
    
    const squaredIntegers = squareList(realNumberArray);
    console.log(squaredIntegers);
    const increment = (function() {
      return function increment(number, value = 1) {
        return number + value;
      };
    })();
    console.log(increment(5, 2)); 
    console.log(increment(5)); 
    const sum = (function() {
      return function sum(...args) {
        return args.reduce((a, b) => a + b, 0);
      };
    })();
    console.log(sum(1, 2, 3));
    const arr1 = ['JAN', 'FEB', 'MAR', 'APR', 'MAY'];
    let arr2;
    (function() {
      arr2 = [...arr1]; // change this line
      arr1[0] = 'potato'
    })();
    console.log(arr2);
    var voxel = {x: 3.6, y: 7.4, z: 6.54 };
    
    var x = voxel.x; // x = 3.6
    var y = voxel.y; // y = 7.4
    var z = voxel.z; // z = 6.54
    
    const { x : a, y : b, z : c } = voxel; // a = 3.6, b = 7.4, c = 6.54
    
    
    const AVG_TEMPERATURES = {
      today: 77.5,
      tomorrow: 79
    };
    
    const LOCAL_FORECAST = {
      today: { min: 72, max: 83 },
      tomorrow: { min: 73.3, max: 84.6 }
    };
    
    function getMaxOfTmrw(forecast) {
      "use strict";
    
      const { tomorrow : { max : maxOfTomorrow }} = forecast; 
    
      return maxOfTomorrow;
    }
    
    console.log(getMaxOfTmrw(LOCAL_FORECAST)); 
    const [z, x, , y] = [1, 2, 3, 4, 5, 6];
    console.log(z, x, y);
    
    
    let a = 8, b = 6;
    (() => {
      "use strict";
    
    })();
    // console.log(a); 
    // console.log(b); 
    const source = [1,2,3,4,5,6,7,8,9,10];
    function removeFirstTwo(list) {
    
      const [, ...arr] = list; 
    
      return arr;
    }
    const arr = removeFirstTwo(source);
    console.log(arr); 
    console.log(source);
    const stats = {
      max: 56.78,
      standard_deviation: 4.34,
      median: 34.54,
      mode: 23.87,
      min: -0.75,
      average: 35.85
    };
    const half = (function() {
    
      return function half({ max, min }) {
        return (max + min) / 2.0;
      };
    
    const person = {
      name: "Zodiac Hasbro",
      age: 56
    };
    
    // Template literal with multi-line and string interpolation
    const greeting = `Hello, my name is ${person.name}!
    I am ${person.age} years old.`;
    
    console.log(greeting); 
    
    
    
    
    const createPerson = (name, age, gender) => ( { name, age, gender });
    console.log(createPerson("Zodiac Hasbro", 56, "male")); 
    const bicycle = {
      gear: 2,
      setGear: function(newGear) {
        "use strict";
        this.gear = newGear;
      }
    };
    
    bicycle.setGear(3);
    console.log(bicycle.gear);
    class SpaceShuttle {
      constructor(targetPlanet){
        this.targetPlanet = targetPlanet;
      }
    }
    var zeus = new SpaceShuttle('Jupiter');
    
    console.log(zeus.targetPlanet)
    
    
    
    function makeClass() {
      class Vegetable {
        constructor(name){
    class Book {
      constructor(author) {
        this._author = author;
      }
      // getter
      get writer(){
        return this._author;
      }
      // setter
      set writer(updatedAuthor){
        this._author = updatedAuthor;
      }
    }
    
    import { capitalizeString } from "./string_function"
    const cap = capitalizeString("hello!");
    
    console.log(cap);
    const capitalizeString = (string) => {
      return string.charAt(0).toUpperCase() + string.slice(1);
    }
    
    const foo = "bar";
    const bar = "foo";