FAQ: Functions - Putting It All Together

What is the error? Are you sure your code is exactly the same? If you could post your code, I’d be happy to try to help. It is possible that the problem is with your browser or device. You can check out this Troubleshooting Guide if you’re certain that your code is correct. The guide explains which browsers and devices work best with Codecademy, and has instructions for making sure everything is up to date.

I hope my weighing in didn’t step on any toes or anything. I just wanted to help someone out.

No worries. There have been times where a temporary glitch with the site is resolved after a few hours, so that may well have been what happened in your case. Seemed to run across just such an instance myself last night in the Python 3 course.

Guys i’m lost i can’t decide wich path i should take
i need a soulotion please !!
TY

Hey @djblack8238907799, welcome to the forums!

We can’t just give you the solution for the exercise. How about you post your code, and we’ll try to help your figure out whats wrong with it?

Hello, how can I make two sandwiches? I have tried with result ‘+’ and ‘,’ but it doesn’t work…

// Define the ‘makeSandwich()’ function
function makeSandwich(topping1,topping2) {
sandwich=‘bread’+’,’
sandwich += topping1 + ‘,’
sandwich += topping2 + ‘,’
sandwich += ‘bread’
return sandwich
}

// Call the function and store the returned value in ‘result’
result = makeSandwich(‘burger patty’, ‘jelly’)
result = makeSandwich(‘jelly’, ‘peanut butter’)

It said that the function is provided in main.js. What is main.js?

main.js is the name of the file where our script is saved. It will be the open tab (or one of them) in the LE.

main_js

1 Like

Hey I’m totally new to this and have one question.
If i change ‘burger patty’ to ‘peanut butter’ and ‘pickles’ to ‘jelly’ in the original function, it works and the sandwich is prepared.
But if i do the whole thing by myself (delete everything and start from scratch), it doesn’t work and always says "Error in code! Expected variable ‘result’ to be defined.
I’ve ensured that everything is correct and done it several times. Is this exercise not ment to be made by oneself and should I just stick with replacing the ingredients in the end.
Help would be appreciated. :slight_smile:

If a math exercise gives us two numbers and expects us to add them, does it count if we change one or both numbers and give the correct result to their addition? Not really. We need to answer the question using the given information.

thanks for your reply

1 Like