Created
May 31, 2022 05:34
-
-
Save robmint/f1aea072019005234661fe294e440f8e to your computer and use it in GitHub Desktop.
cat javascript for Luna
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Cat() { // cat factory, called a Constructor | |
this.furry = true; // this is the info that every cat has to start with | |
this.name = ""; // but can be changed | |
this.legs = 4; | |
} | |
cat = []; // make a new list of cats: [] means a numbered list starting at 0 | |
for(var i=0; i<5; i++) { // go through the list creating 5 cats | |
cat[i] = new Cat(); // use the Cat() factory to make a new cat and store it in the list of cats | |
} | |
cat[0].name = "Lulu"; // set the name of cat[0] | |
cat[1].name = "Austin"; // set the name of cat[1] | |
console.log(cat); // print out the whole list of cats | |
console.log(cat.length); // print out how many cats we have |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment