Can't pass 4/10 on JavaScript Functions


#1

https://www.codecademy.com/courses/learn-javascript-functions/lessons/functions/exercises/parameters-ii?action=lesson_resume&course_redirect=introduction-to-javascript

I’ve been stuck on this part of the functions module for 2 days now and I can’t figure out what I’m doing wrong with this module. Please help me, here is my code:



const takeOrder = (topping, crustType) => {
  console.log('Order:' + crustType + 'pizza topped with' + topping);
}

takeOrder(bacon, thin crust);
takeOrder(mushrooms, pan crust);
takeOrder(sausage, flatbread);



#2

You are missing the ’ ’ around your arguments. Because the arguments are a string you need to put them in quotes, otherwise JavaScript thinks these are variables, looks for them in your code and then returns an error when it can not find their definitions (bacon is not defined). There is another issue with a missing argument but that is fixed with adding the quotes.

takeOrder('bacon', 'thin crust');
takeOrder('mushrooms', 'pan crust');
takeOrder('sausage', 'flatbread');

You may also consider adding spacing to your console.log message like this. This way when console returns the message the spacing is correct.

console.log('Order: ' + crustType + ' pizza topped with ' + topping);

Not sure if this helps but when I was starting down the JS path, if the code fails, I would copy the code, open a new tab, open the browser developer tools (F12 Chrome) and go to console. Then I paste the code in there and run it. If the code fails there is usually an error message that I would use to track down the issue.

Good Luck :smiley:


#3

This was super helpful, thank you so much!


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.