Knowledge check: Advanced JavaScript Features

Knowledge check: Advanced JavaScript Features

  1. What will print out when the following code runs?

     const meal = ["soup", "steak", "ice cream"]
     let [starter] = meal;
     console.log(starter);
    
    • soup

    • ice cream

    • steak

  2. The for-of loop works for Object data types.

    • true

    • false

  3. What will print out when the following code runs?

     let food = "Chocolate";
     console.log(`My favourite food is ${food}`);
    
    • My favourite food is Chocolate

    • My favourite food is ${food}

  4. What values will be stored in the set collection after the following code runs?

     let set = new Set();
     set.add(1);
     set.add(2);
     set.add(3);
     set.add(2);
     set.add(1);
    
    • 1, 2, 3, 2, 1

    • 1, 2, 3

  5. What value will be printed out when the following code runs?

     let obj = {
         key: 1,
         value: 4
     };
    
     let output = { ...obj };
     output.value -= obj.key;
    
     console.log(output.value);
    
    • 1

    • 2

    • 3

    • 4

  6. What value will be printed out when the following code runs?

     function count(...basket) {
         console.log(basket.length)
     }
    
     count(10, 9, 8, 7, 6);
    
    • 10, 9, 8, 7, 6

    • 1, 2, 3, 4, 5

    • 6

    • 5