Learn Introductory JavaScript by Building a Pyramid Generator - Step 55

Tell us what’s happening:

My code returned the sum of the two numbers, but it said it’s hardcoded. Please help

Your code so far

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

function padRow(name) {
  return name;

// User Editable Region

}
function addTwoNumbers(sum) {
  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 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 55

In order to add two numbers together, you need two numbers. Your function is only receiving one number.

The sum is the result of adding two numbers and needs to be returned by your function.

Let me know if you need to explain any further.

I’m new to JS (As you can see by the project lol) so I would like a little bit more detail on your explanation if it won’t be much of a bother to you.

Thank you!

You currently have one parameter in the ``addTwoNumbers` function. You need two parameters. Two parameters that you add together and return.

Hey there,
This is a tricky one. It’s worded pretty poorly imo and so you could code it many ways to get the desired outcome (sum=15), but it only accepts 1 method. Even going back to this (finished it weeks ago) again, it took a little while to find the right answer.

The first thing is, which has already been pointed out, is your function needs two paramters, which are the variables inside the brackets(). You have one, called sum. I would actually not name either of the parameters sum to avoid confusion. Call your parameters any other thing you want, but just use letters and no spaces. Seperate with a comma. Example: function howdy(train, dude)

The next problem is in this code const sum = addTwoNumbers(5 + 10). You may think you are passing two arguments to this function call, but you are actually only passing one. The arguments need to be seperated with a comma. Right now, the code is just interpreting a single argument of 15.

At this point all you are missing is the logic that performs the math. I will leave it to you to figure out where that goes and what it looks like (hint: it’ll use your parameters as variables, no numbers involved).

feel free to open an issue on github with your suggestions on how to improve the step

I’m still really confused. My apologies, but I would really need it in simpler terms.

function addTwoNumbers(x, y) {

return x, y;

}

const sum = addTwoNumbers(5, 10);

console.log(sum);

That’s my code so far.

Thank you!

It’s only displaying the number 10 and not adding the 5

Look at your return line. It’s trying to return two numbers separated by a comma ,

You want to return the SUM of x + y which means you should use a + to add them, right?

Oh my, that worked! Thank you so much mate!

Also thank you to every who tried to help me through this!

welcome to JS
Declare a sum variable and assign it the value of calling your addTwoNumbers function with 5 and 10 as the arguments. Log the sum variable to the console.

do this step by step

  1. create function
  2. pass arguments two arguments as your wishes like english alphabet
  3. return and do sum calculation inside the curly braces
  4. after creating the function
  5. Declare a sum variable assign it the value of calling your addTwoNumbers function with 5 and 10 as the arguments
  6. finally log it in the console
    this is the way to understand the concept

because your function have only one arguments so it display one argument
however you written the function not as per the instruction