Literally Speaking - prints to console, but still receive an error


#1

My code does what it is suppoesed to do and prints both lines to the console, but I still get an error message. The error says, "Oops, try again. It looks like your speak method doesn't properly take in a single argument and output the correct string."

I tried looking at older threads and my code seems similar to others' that have worked. I'm sure it's something simple that is causing this error, but I am overlooking whatever it might be.

https://www.codecademy.com/courses/objects-ii/0/3?curriculum_id=506324b3a7dffd00020bf661#


var james = {
    job: "programmer",
    married: false,
    speak: function(mood) {
        console.log("Hello, I am feeing " + mood);
    }
};

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


#2

You have to add l to feeing -> feeling :slight_smile:


#3

facepalm Haha, I definitely need to read more carefully! :smile:


#4

you will also need to add a space when printing the output.

console.log("Hello, I am feeling" + " " + mood);


#5

You're very welcome :slight_smile:


#6

There already is a space in:

console.log("Hello, I am feeing " + mood);

#7

@ factoradic with that code my output didnt show any space so i have to add space on mine.


#8

Are you sure? That sounds pretty weird.

I want to point out that there is a difference between:

console.log("Hello, I am feeling " + mood);

and

console.log("Hello, I am feeling" + mood);

May I ask you to try again? Please copy and run this code:

var james = {
    job: "programmer",
    married: false,
    speak: function(mood) {
        console.log("Hello, I am feeling " + mood);
    }
};

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

and if you don't see a space in the output please post the screenshot. Thank you.


#9

@factoradic here's the code without the space i added.

console.log("Hello, I am feeling" + mood);

the output:

Hello, I am feelinggreat
Hello, I am feelingjust okay

that's why i added a space.


#10

@factoradic you're right due to the reason i didn't put a space after the feeling" thats why i need to add a spece.
Like what you suggested i can also put a space after the feeling that i just recently noticed feeling(spacebetween)"

Thanks for the heads up.


#11

A slightly more subtle problem.
The code

var james = {
    job: "programmer",
    married: false,
    speak: function(mood) {
        console.log("Hello, I am feeing", mood);
    }
};

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

prints what seem to be the correct strings, but fail. I guess that it prints two sequences of two strings.


#12

You have to add l to feeing -> feeling


#13

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