Generation

generate functionMon, 14 Nov 2022

create an object within an object and print its properties to console

var student = { firstName: "Mark", lastName: "Foo", age: 24, favoriteMovies: ["Star Wars", "Lord of the Rings", "Star Trek"] }; function print(person) { console.log(person.firstName + " " + person.lastName + "is" + person.age + "years old."); console.log("His favorite movies are:"); for (var i = 0; i < person.favoriteMovies.length; i++) { console.log("-" + person.favoriteMovies[i]); } } print(student);

Javascript
Generate More

Questions about programming?Chat with your personal AI assistant