We're running a test below to make sure your code works. -- What test?


#1

In Loop the Loop under the code output:

We're running a test below to make sure your code works.
alicebobmichelletimmy

What/how are they testing (for)? I'm guessing I passed (aside from the green go-ahead button) because I saw something(s) different looking for an an answer to this question in the forum, but I was wondering if anyone knows what the test is, both out of sheer curiosity and in case it's useful to use myself on a future exercise or program.

Thanks everyone!
frisby

https://www.codecademy.com/courses/spencer-sandbox/4/2?curriculum_id=506324b3a7dffd00020bf661#


// Our Person constructor
var Person = function(name, age) {
  this.name = name;
  this.age = age;
};

// Now we can make an array of people

var family = [];

family[0] = new Person("alice", 40);
family[1] = new Person("bob", 42);
family[2] = new Person("michelle", 8);
family[3] = new Person("timmy", 6);

// loop through our new array

for (i = 0; i < family.length; ++i) {
  console.log(family[i].name);  
};


#2

@msfrisby,
Place the total code in labs
and correct the errors
1 at a time, starting at the top of message's

var erson = function(name, age) {
  this.ame = name;
  this.ge = age;
};

// Now we can make an array of people

var family = {};

family[0] = new Person("alice", 40);
family[1] = new Person("bob", 42);
family[2] = new Person("michelle", 8);
family[3] = new Person("immy", 6);

// loop through our new array
/*
for (i = 0; i < family.length; ++i) {
  console.log(family[i].name);  
}
*/


//make sure the Person constructor works as expected
try {
     var michael = new Person("michael", 21);
    //console.log("trying");
    //throw "exep"
    }
    catch (e) {
            console.log("catching"+ e.message);
        if (e instanceof ReferenceError) {
        console.log( "When trying to create a new Person"+
            " a ReferenceError was thrown. "+
            "Make sure you properly created the Person constructor."+
            " Here's the message: " + e);    }
console.log( "When trying to create a new Person the "+
"following error was thrown: "+e);
//+e1;
}



if (michael.name !== "michael") {
    console.log("It looks like your Person constructor "+
    "does not properly save the first argument as the person's name");
    }
if (michael.age !== 21) {
    console.log("It looks like your Person constructor does not properly "+
    "save the second argument as age");
    }

//make sure that the family array was created correctly
try {
    if (!(family instanceof Array)) {
        console.log("Make sure you created an Array called family");
        }
    }
    catch (e2) {    if (e2 instanceof ReferenceError) {
        console.log( "Make sure you created an Array called family! "+
                "The following ReferenceError was thrown when "+
                "trying to test family: " + e2);
                }
        console.log("The following error was thrown when trying "+
                "to test the family array: " + e2);
                }

//test contents of family

var names = ["alice","bob","michelle","timmy"];
var ages = [40,42,8,6];
var allPrints = names.join("");
// this should be all the things that were printed all in 
//one line for better checking

console.log("---We're running a test below to make sure your code works.");
console.log(allPrints);

for (var i = 0; i < family.length; i++) {
    if (!(family[i] instanceof Person)) {
        console.log( "It looks like the object at index " +
            i + " was not created with the Person constructor");
            }
    if (family[i].name !== names[i]) {
        console.log( "It looks like the Person at index " + 
            i + " isn't named " + names[i]);
            }
    if (family[i].age !== ages[i]) {
        console.log( "It looks like the Person at index " + 
            i + " isn't " + ages[i] + " years old");
            }
    if (allPrints.match(new RegExp(family[i].name)) === null) {
        console.log( "Make sure to log to the console the name "+
        "of each object");
            }
    }
/*
if (error) {
    return "It looks like you have an error in your code. "+
    "Here's the message: " + error;
    }
    */

27/33 Where is this coming from?
#3

@leonhard.wettengmx.n Wow, so basically it's a whole separate program designed just to catch potential errors? I did run it and it was really fun to see how the messages were adjusted at each step :nerd: