What do the function?

Hello everybody :grin:What this function do step by step , I made it but I’m confused ))))
thank you for explain ))

function makeClass() {
  "use strict";
  /* Alter code below this line */
class Vegetable {

  constructor(name) {
    this.name = name;
  }



}
  /* Alter code above this line */
  return Vegetable;
}

const Vegetable = makeClass();
const carrot = new Vegetable('carrot');
console.log(carrot.name); // => should be 'carrot'

You wrapped your class (constructor function) Vegetable with another function makeClass. For better understanding I’ll use real world analogy. Imagine function is a box and people normally put useful stuff or functionality inside. Imagine that browsers are people of different age depending on version of browser. So now, taking that into consideration here’s step-by-step guide of your code:

  1. You have magic constructor-box - whenever you open it there’s a vegetable inside!
  2. Problem with that box - it cannot be opened by really old people (we’re talking 100yr+ here)
  3. So what you do, you put your Vegetable box inside another box and put small piece of paper use strict which means only for people 100 year-old or less.
  4. Then action time, you open one box and open another box

The moral of this story is, do you really need that second box? Have you even seen 100+ year-old people?

Thank you for explain )