JSFiddle - React, Tailwind, and code Playground
by akang2
JavaScript
//Act 7.5 Generating Object Instances
/*A function could be used to create multiple instances
1) Make the function return an object literal containing a person's information.
2) Call the function twice, creating two objects with different properties.
3) Store those objects into variables (optional, but recommended).
4) Use console.log() to print information about each instance.
*/
function createPerson(carName, carAge) {
return {
name: carName,
age: carAge
};
}
var per1 = createPerson('vin', 12);
var per2 = createPerson('ben', 18);
console.log(per1);
console.log(per2);