Learn Introductory JavaScript by Building a Pyramid Generator - Step 55

Tell us what’s happening:

The directions are: make a function called addTwoNumbers. And 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.

I don’t know how to pass this one.

Your code so far

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

function padRow(name) {
  return name;
}

// User Editable Region

function addTwoNumbers(5, 10) {
  return 5 + 10;
}
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 + 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

Welcome to the forum @asdfghjkl1

Have a look at the example code.

You need to use variables in the function declaration.

Happy coding

Hi @asdfghjkl1, the function DEFINITION is a series of steps that describe how the function works when the arguments are passed to it.
In your code, function addTwoNumbers(5, 10) should be replaced with variables (for instance, a and b). While CALLING the function, you should pass the values 5 and 10 instead of a and b.

So, your updated code would be as follows:
code removed by moderator

I hope you understand this! Thankyou.

Hi @mounich2856

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.

Thank you I finally passed it. The code should’ve been with the numbers 5 and 10 in the function and return replaced with the variable a and b.
Then I added to the code I called the function under it:
function name of function(number1, number2);

(for anyone else that gets stuck on this)

1 Like

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