Help neededwith "i can haz cheezburger" function

it’s a practice exercice but i can’t find where is my error
here’s the statement:
Write a function icanhaz() that lets you customize the “i can haz cheezburger?” meme. Your function should have a string argument. If invoked with no argument, your function should return the string "i can haz cheezburger?" . Otherwise it should return "i can haz [argument]?" .

// Returns: i can haz presentz?
icanhaz('presentz');

// Returns: i can haz cheezburger?
icanhaz();

My code:
function icanhaz (argument = ‘cheezburger’){

console.log (i can haz ${argument}?)

};
thanks

the crucial word in this instructions is return, you currently log the string.

1 Like

Hello, i’m stuck in this very same question. My code is similar to his. I’ve tried some versions using the return keyword. My code works, But it says theres still an error.

What would it be?

Impossible to say without seeing the code. I am developer, not a magician :wink:

but did you understand what you tried and why?

2 Likes

Hi. I’m also having the same issue with this exercise. I would really appreciate if you give more insight as to where the problem is. You can see the code below, I’ve included return as you suggested and the function output is correct however I still don’t get a pass on this exercise. many thanks.

function icanhaz (thing = 'cheezburger') 

{

return console.log(`I can haz ${thing}?`);

}

icanhaz();

icanhaz('presentz');

If we return a value, we can use this value outside the function. Which means we can capture the returned result in a variable:

const result = icanhaz();

and then log it:

console.log(result);

or log the returned result right away:

console.log(icanhaz());

we should then get the string, yet we get undefined.

that is because you return the result of the .log() method in your icanhaz function, which doesn’t have a return value.