Learn Introductory JavaScript by Building a Pyramid Generator - Step 55

Tell us what’s happening:

I don’t understand how to make this function return the sum of two numbers. Can anyone help me with this?

Your code so far

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

function padRow(name) {
  return name;
}

// User Editable Region

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

// 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 + "\n" + row;
}

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/128.0.0.0 Safari/537.36

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 55

hi there!

your function is missing its paramaters. you need two paramaters for the function. and you need to return the sum(adding) of that two paramaters within the function body. you are currently returning the sum variable.

Im sorry I don’t understand, where do I put the parameters? I think in the paranthesis after addTwoNumbers in the function? But i dont know what to make them. Is this closer?

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

that is now correct.

that should be return the sum of your two paramaters a,b.

that was previously right. you changed it.

I tried this but it’s still not right?

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

there isn’t a sum function to use, you need to use the addition operator, +

Like this? I am really lost…

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

no, the arguments were right, change here the return statement to not use sum which doesn’t exists

I still can’t figure it out

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

you need to use + to sum the two numbers, here in front of the return

you need to return adding a and b.

1 Like

I tried this and I think it is closer, now it just says “your sum variable should have the value 15”

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

the arguments should not be add to each other, its should be have a comma between the both argumnts.

1 Like

THANK YOU! I finally got it to work after so much time

1 Like

Your welcome. Happy Coding.

1 Like