Learn Introductory JavaScript by Building a Pyramid Generator - Step 55

Tell us what’s happening:

i cant seem to figure out what the problem is ive tried everything

Your code so far

const character = "#";
const count = 8;
const rows = [];

function padRow(name) {
  return name;
}

// User Editable Region

function addTwoNumbers(firstNumber, secondNumber) {
  return 5, 10;
}
console.log(5 + 10)

// User Editable Region


const call = padRow("CamperChan");
console.log(call);


for (let i = 0; i < count; i = i + 1) {
  rows.push(character.repeat(i + 1))
}

let result = ""

for (const row of rows) {
  result = result + row + "\n";
}

console.log(result);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 55

Hi @Sinan

Your function is hard coding the output.
You function will always return 10 no matter what is passed to it.

You need a way to return whatever is passed to the function, so that the two numbers are added together.

Happy coding

Hi there!

You should return the sum of your two parameters.

And here you need to assign the function call to a variable sum and add two numbers as a argument within the function call.

i still dont get it every time i write sum it says sum not defined

What did you won’t get in my above post?

if i write sum it says sum not defined like when i write console.log(sum) or return sum but if i dont write sum it says you must write sum

You need correct your return statement first.

Look, you have fisrtNumber and secondNumber as a parameters for the function addTwoNumbers.

You aren’t returning the sum of two parameters in above return statement. You need to return the sum of that two parameters.

How did you sum two numbers together?

now i have this:
function addTwoNumbers(firstNumber, secondNumber) {
return(firstNumber, secondNumber);

}
console.log(5 + 10);

hold on i couldnt put the whole thing

oh that was the whole thing

That’s not a valid return statement. Also you aren’t sum’s the two parameters together.
Here’s an example of returning multiplying two parameters:

return one * two;

i still dont know where to put sum!

Did you updated your code as I suggested as given example. Show your updated code in your next reply.

function addTwoNumbers(firstNumber, secondNumber) {

return(five + ten);

}

console.log();

You didn’t have five and ten as a parameters. You have firstNumber and secondNumber as a parameters. Also you didn’t need the round braces around.

now i have this for adding sum: function addTwoNumbers(firstNumber, secondNumber) {
return firstNumber + secondNumber;
function sum(5,10)
}
console.log(sum);

Remove the above code form the function. It’s not valid.

Now You need to declare the variable called sum using const keyword and assign it the function call addTwoNumbers. Example of calling a function =>functionName(). Then add two numbers as a argument within the function's ()` separated by a comma.

still not working !!! function addTwoNumbers(firstNumber, secondNumber) {
return(firstNumber, secondNumber);
const sum(five, ten);

You have changed the return statement again and deleted the closing } bracket of the function body.
Return sum example:

return one + two

Here’s you declared sum variable as a function call.

Declaration and assignment example:

const variable = functionName(arg1, arg2);

im starting to give up:
function addTwoNumbers(firstNumber, secondNumber); {
return(five + ten);

}
const sum = addTwoNumbers(sum); EDIT: I reset the code and lost part of it