3. Literally Speaking


#1



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


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


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

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


#2

you need to use the mood variable inside your console.log, so that when you call the method:

james.speak("great");

the mood gets reflected inside the console.log. simple example:

var james = {
  example(parameter){
    console.log(parameter)
  }
};
james.example("see how");
james.example("this works?")

see how you can use the function parameter (in your case mood) to reflect the different moods inside the method?


#3

then what about these instructions i am given,

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.


#4

mood will hold the string "just okay" when you call it:

james.speak("just okay");

so you would need to join the string with the variable:

speak: function(mood) {
  console.log(/* string + mood */);
}

#5

oh lemme check then....


#6

speak: function(mood) {
console.log(/* string + mood */);
}

it doesn't work again same error

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


#7

what does mean by that method is not taking properly in a single argument when we are suppose to define only one argument.


#8

you still need to put the string and the variable together, i can't do everything for you:

var test = "joining a"
console.log(test + " variable and string together")

#10

speak: function(mood) {
console.log("Hello, I am feeling great "+mood);
console.log("Hello, I am just okay "+mood);
}


#11

mood will hold the string you pass it when you call the method:

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

so you need just one console.log with "Hello, I am " plus the the mood variable, since that will hold whatever you pass as argument into the method.

I highly recommend you to reflect on functions, function parameters and function arguments. (methods are functions inside objects)


#12

God no way i tried this also