How to initialize to an empty array if my 'students' parameter is not passed

Solution 1:

You could use a default value if the param is not passed. In this way, your properties will be initialized with default values.


    class Bootcamp{
        constructor(name = '', level = 0, students = []){
            this.name = name;
            this.level = level;
            this.students = students;
        }
    }