Intro to JavaScript: Function Exercise (icanhaz())

Hey guys, I’ve been trying to figure out this particular Function exercise. It’s the quiz that I have to take after completing the Function segment. It can be found here:

I’m at the part where it asked me to write the icanhaz() function. This is what I currently have. After few trial and errors, I still can’t get it right. I’d really appreciate it if anyone is able to assist me on this. Thank you very much.

Hi @snailmachine

I’m not great with JS, tbh, but… there’s one obvious thing where you’ve gone wrong, that I can see.

In your else block, you have this:

} else {
  return 'i can haz presentz?';

The exercise requirement states that if an argument is provided - i.e. icanhaz("french fries"); - the function should return “i can haz french fries”, so there should be a string returning i can has [argument], which you aren’t doing. :slight_smile:

Hey there @thepitycoder, thanks for providing me the tips! Assigned a parameter to the function and it works. Appreciate it mate!

1 Like

Hello. I tried to do this task in a slightly different way. The solution comes out good. I don’t know, however, why it is incorrect after all.


you have to use return keyword i think


@dev6300938908 is spot on:


1 Like

Hmm… Having trouble as well - I have done about 4 successful variations to produce what the instructions said - here are some screenshots… Idk why it wont pass me? I have tried the above ones as well.

What is the return value of console.log('i can haz cheezburger?');?

I’ll give you a hint, it’s not the value i can haz cheezburger? which the exercise is asking for.

function icanhaz(name = "cheezburger"){
 console.log(`"i can haz ${name}?"`)

This is returning the correct answer, but the continue button just cycles me around.

How do I add a screenshot?

I took a shot of your code, rewrote mine exactly the same (except the word should be presentz and is supposed to have “”) and it still comes up wrong…

function icanhaz(name='cheezburger'){
  return(`"i can haz ${name}"`)


also did it with out the ("), just () and then tried (")… nothing works

Oh, well, nevermind… hit f5 and it took me back to the do the entire review again.

That is very helpful!