Imagine this scenario: I have a constructor function like the one below:
function Planet(solarSystem, habitable) {
this.solarSystem = solarSystem;
this.habitable = habitable;
}
Now, let's say after having a few too many beers, I try to create an instance of this constructor function with incorrect parameters:
let earth = new Planet(23, 'wooow');
Your task is to figure out how to set up a condition for creating the instance where it only happens if the parameter types are correct. If not, don't assign anything to earth
.
Note: The expected parameter types for the Planet
constructor function are Planet(String, boolean)
. Keep that in mind while solving this problem.