Learn Introductory JavaScript by Building a Pyramid Generator - Step 55

Tell us what’s happening:

What’s wrong with this code?..

Your code so far

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

function padRow(name) {
  return name;
}

// User Editable Region

function addTwoNumbers(sum1 , sum2) {
  return "5 + 10";
}

addTwoNumbers("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 + "\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/130.0.0.0 Safari/537.36

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 55

you created the parameters, you need to use them in the function

I thought you use them by stating return “5 + 10”?

you should follow your code here and apply the same structure, “call” is your sum.

const sum = padRow??

const sum = addTwoNumbers( first number, second number);

dont forget to log the sum

const sum = addTwoNumbers(5 , 10);

console.log(sum); ?

The tutor prompt says ‘you should have a function called addTwoNumbers’…

function addTwoNumbers(5, 10) but instead of 5 and 10 put num1 and num2, same for the body (of the function), you need to add a return adding num1 and num2

Like this?:
const sum = function addTwoNumbers(num1 , num2);

return “num1 num2”;

console.log(sum);

no, to use the parameters you need to write the parameters names

code removed by moderator

if you are calling the function you don’t use the function keyword. You also need to give two numbers there. The return keyword works only inside a function

hey @mtz.libby

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.

@mtz.libby solution seems like a different answer

I tried explaining it in the simplest form, didn’t mean to give away the answer. I will let you to try to explain it.

what is your code now? please share it again

const sum = function addTwoNumbers(num1 , num2){

return “num1 num2”;

}

console.log(sum);

in this line, if you use quotes you are returning a string, you need to sum the two parameters with the + addition operator, in that way you are returning the sum

for this line, you need to separate the function definition and the sum variable. Remove the const sum = from the beginning of the line. Add it after the function definition, you need to call the function (use the function) passing in two numbers to the function

this is an example of calling a function with one argument

like this?:

function addTwoNumbers(num1 , num2){

return num1 + num2;

}

const sum = addTwoNumbers(“5”,“10”);

console.log(sum);