Fun with Functions



Hello Please guys tell me what's wrong in this code

** :confused:

function Person(job, married) {
this.job = job;
this.married = married;
// add a "speak" method to Person!
var speak = new Person();

var user = new Person("Codecademy Student",false);

Add a speak method to the Person constructor. Whenever speak is called, it should print "Hello!" to the console.


// add a "speak" method to Person!

how to add a method:

this.someMethod = function() {


so you should do



What's stopping you from finding out?
Have you tested your code? Does it behave as described? Identify the problem.


thanks now it works :slight_smile:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.