Learn Introductory JavaScript by Building a Pyramid Generator Step 54

Again, I literally did everything the step said, and I did it right, but it’s still giving me errors.

Here’s the code:

function addTwoNumbers(5, 10) {
return 5 + 10;
}
const sum = addTwoNumbers(5, 10)
console.log(sum)

It’s giving me ridiculous error messages like telling me there’s a missing semicolon between (5, 10) and the first curly bracket, where one shouldn’t be, and telling me that I should have a function, declare ‘sum,’ etc., when I have literally done all that.

It’s driving me crazy and I’m about to cry. Someone please help.

(I’m posting this from my phone so I can’t post the code directly.)

A function declaration should take two arguments (not numbers), and return the sum of these arguments (not numbers). For example:

function someFunction(arg1, arg2) { ...

The code you entered after the function declaration is OK.

2 Likes

Okay, so instead of addTwoNumbers(5, 10), something like addTwoNumbers(num1, num2), then assign the numbers to those parameters…right?..

I’ll try it…

Edit: Okay, it worked! Thanks :blush:

2 Likes

what u need to learn is two thing ,

declaration

//anonymous function , no argument, no name for it//
function (){
return "nothing"
}
//function with a name//
function blend1(){
return "huhu" 
}

//function with blend2 as a name and take two arguments//
function blend2(first , second){
return "two fruits is blending"
}

//u can simply make the function take as much as u wanted it to take//
function blend3(first, second, third){
return "three fruits is blended"
}

call for the function

//if u wan to call (use the function)
//simply type back the name u gave and pass in the argument u wanted to use

blend2("apple","banana")

//the use of return is to access the result, normally we will store it in a variable and console log to see it //

result = blend2("apple","banana")

console.log(result)

output on console = "two fruits is blending"

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

I literally just asked someone not to spam solutions

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