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: https://www.codecademy.com/courses/introduction-to-javascript/lessons/functions/practice?utm_source=customer_io&utm_campaign=progress_review&utm_medium=email&utm_content=content_button

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:

1 Like