This course has already ended.

JS2: Attendance and activity

Stack Overflow Statistics

  1. What is the difference between for..in and for..of?

  2. Do you know what spread operator (…) does? (not course content, but good to know)

const arr1 = [1, 2, 3];
const obj1 = {a: 1, b: 2, c: 3};

const arr2 = [...arr1];
const obj2 = {...obj1};
  1. What happens here:

    let arr = [[]];
    
  2. How about here:

    table_row += "</tr>";
    

    What is the operation (+=) called?

Manipulating StackOverflow data

  1. What is the difference between ++counter and counter++?

  2. Please explain what happens here:

    let year = 2020;
    let yearlyTechStats = {};
    const yearlyTechs = Object.keys(stackOverflowStats[year]);
    for (const tech of yearlyTechs) {
      if (tech.startsWith("current")) {
        yearlyTechStats = {...yearlyTechStats, ...stackOverflowStats[year][tech]};
      }
    }
    
  3. How about here:

    let html = '';
    
    for (const row of rowData) {
      html += `<tr><td>${row.join('</td><td>')}</td></tr>`;
    }
    
  4. Can there be many theads in a table - how about many tbodies?

Co-authors

  1. What happens here? What does it mean if something will change in-place?

    let years = [2015, 2000, 2019, 2017];
    years.sort();
    
  2. Check sort documentation sort() called with or without a callback. Why doesn’t the following code snippet behave as expected? How would you fix it?

    let numbers = ['11', '101', '1', '1001'];
    numbers.sort();
    console.log(numbers);
    
  3. In the following code snippet includes() check is made to prevent duplicate items in years.

    const years = [];
    for (const year in publications) {
        if (!(years.includes(year))) {
          years.push(year);
        }
    }
    years.sort();
    return years;
    

    Besides Array and Object, there is a built-in object for unique items only (not in course material)? Any suggestions?

  4. If you get a NodeList or a Set, but need to switch the object to an array, how would you do that?

A+ presents the exercise submission form here.

Posting submission...