There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply () below.
If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.
Join the Discussion. Help a fellow learner on their journey.
Ask or answer a question about this exercise by clicking reply () below!
Agree with a comment or answer? Like () to up-vote the contribution!
I see I was mixing it up with the single line version. It’s cool that it can be shortened even further, and technically doesn’t need the ternary operator…
Good stuff, thanks!
Regarding your question, the (string) parameter was already included in the function declaration. According to the lesson instructions, the purpose of the containsCake function is to take a string and check if that string contains the substring 'cake' inside of it.
I tried omitting the (string) parameter, like in your last example, but it throws back an error.
While the easiest answer is to use the “contains” method, the Stack Overflow article and responses clearly shows that it does not work on Internet Explorer or other older ES5 browsers. This does not make a huge difference these days, but there are people out there who use older systems, so I would suggest that using “indexOf” would be a more complete solution. That, or using a polyfill…