Learn Introductory JavaScript by Building a Pyramid Generator - Step 55

Tell us what’s happening:

someone please help me with step 55 on how to setup up a sum variable and entirely also how to set the function. on introductory to java script by building a pyramid generator

Your code so far

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

function padRow(name) {
  return name;
}

// User Editable Region

function addTwoNumbers(value1=5,value2=10){
  return value1 + value2;
 sum()=value1+ value2;
  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/126.0.0.0 Safari/537.36

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 55

I am having an issue with this same step. My code is:

removed

I’ve also tried using let instead of const. The error documentation says ‘create a function called addTwoNumbers’, but it’s seems pretty clear I have done this. Not sure what my mistake is.

can you please use the Ask for help button to open your own topic?

you need to create a sum variable outside the function, you need to call addTwoNumbers and assign the call to the sum variable you create

now my main concern is how do we do that

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

The same way that you’ve created the padRow() function. Refer to that code and do it in the same way.

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

any further instructions from this point?

in all of this there isn’t a call to addTwoNumbers


for the function, you need to return a sum, using +, and you need to remove all those =5and =10

Take it step by step. Don’t try to do the whole thing at once. Understand fully each line that you write, don’t try to guess or use “AI”.

Do you have a question about what you’ve written so far?

You are not adding the two variables together correctly in your function. Do you know how to add two numbers together?

  • Declare a function named addTwoNumbers. :white_check_mark:
  • This function should take two arguments :question:
  • and return the sum of those two arguments :x:

You’ve defined the function to take two arguments, but you’ve added default values, which the instructions do not ask for. If you add things that the instructions don’t ask for, it will not pass the test.

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.