Learn Introductory JavaScript by Building a Pyramid Generator - Step 55

Tell us what’s happening:

I don’t understand what to do, it’s telling me I should not be returning a hard-coding value, however I do not know what to do about this. Please help me.
Thanks

Your code so far

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

function padRow(name) {
  return name;
}

// User Editable Region

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

// 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 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 55

you need to use the two parameters.

1 Like

Welcome to the forum @lmerritt932

Part one:

Declare a function named addTwoNumbers. This function should take two arguments and return the sum of those two arguments.

Part two:

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.

You correctly declared the addTwoNumbers function.

However, the body of the function is not quite right.
It needs to add the two parameters. At the moment, the function will return the sum variable, instead of what is passed to it.

Happy coding

function addTwoNumbers(a, b) {

return (a + b);

}

let a = 10;

let b = 15;

let sum = addTwoNumbers(10 + 5);

console.log(sum);
so now it’s saying that sum doesn’t equal 15, any way for me to fix this?

There is a typo in one of your values above. You’re on the right track, you need to have code inside the curly brackets to complete the function. The addTwoNumbers function needs to return sum, and in order to do that you need to use the two parameters that are provided.

when you call the function, you need to pass in two arguments separted by a comma

Thank you, my code works now.