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.

1 Like

you have to use return keyword i think

1 Like

@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.