2/30 am i doing something wrong?


#1

function Person(job, married) {
this.job = job;
this.married = married;
// add a "speak" method to Person!
this.speak = function() {
console.log("Hello");
}
};

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

i tried using the //console.log and print. and still nothing is there something else wrong? and i get this message "It looks like 'Hello!' wasn't logged to the console. Make sure that you properly defined the method and that you didn't change any of the provided code."


#2
they ask

'Hello!'

you use

'Hello'


#3

i tried but still got "Oops, try again. It looks like 'Hello!' wasn't logged to the console. Make sure that you properly defined the method and that you didn't change any of the provided code."


#4

Have you added an exclamtion-mark-! to your Hello ??


#5

This is what @leonhard_wettengmx_n is trying to tell you to do

function Person(job, married) {
    this.job = job;
    this.married = married;
    // add a "speak" method to Person!
    this.speak = function() {
        console.log("Hello!"); //add exclamation here
    };
}

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

#6

@leonhard_wettengmx_n
@rydan

I'm also stuck here, and I got your point.
I add exclamation mark to the word "Hello" but still the error comes out the same.
It tells me like this; "Oops, try again. It looks like 'Hello!' wasn't logged to the console. Make sure that you properly defined the method and that you didn't change any of the provided code."

This is my code:

function Person(job, married) {
this.job = job;
this.married = married;
// add a "speak" method to Person!
this.speak = function () {
console.log("Hello!");
};
}

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


#7

@jfrancis21,
I tried your code using a windows 8.1 IE11 environment and got a pass....

Maybe...
++++ reset of session *****************
As you are manipulating with objects
under certain circumstances you can shoot your Browser in an
inconsistent state.

Therefor it is of an advantage to know that you have 2 reset facilities:

One is the use of the F5-key which does a refresh Browser

and

Two, select&copy your code
Then use the Reset Code button of the course-window,
then paste your code back in.

Addendum
General Notes:
Always refresh the browser after making corrections:
CTRL f5 ( if on Windows or Linux)
CMD r ( if on a MAC).


#8

Strangely enough this simple piece of code and the one of the next exercise wouldn't work. The one thereafter is working. Silly enough when I copy-paste Rydan's code in the editor it does work.

Checked, and double checked really everything until I didn't knew anymore what I was reading. Including the exclamation mark. Also the page refresh and page refresh with reentering didn't work.


#9

@codesurfer78083,
Please present the code you are using/writing-aboot...


#10
var james = {
    job: "programmer",
    married: false,
    speak: function(mood) {
        console.log(mood);
    }
};

james.speak("great");
james.speak("just okay");

Gives me:

Oops, try again. It looks like your speak method doesn't properly take in a single argument and output the correct string.


#11

@codesurfer78083,
Here the Instructions:
Take a look at the partially-defined james object.
Complete the speak method such
that the last two lines in the editor will cause

"Hello, I am feeling great"

and

"Hello, I am feeling just okay"

to be printed to the console.


#12

Thanks, overlooked that. Still don't understand what was so hard about the exercise before that though, but since I successfully copied Rydan's code, I think I'll leave it at that.


#13

This will work for you all guys. :grinning:

function Person(job, married) {
    this.job = job;
    this.married = married;
    // add a "speak" method to Person!
    this.speak = function () { 
        console.log("Hello!");
    };
}

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

#14

this works you had an extra bracket
this.job = job;
this.married = married;
// add a "speak" method to Person!
this.speak = function() {
console.log("Hello!");
};
}