Learn Introductory JavaScript by Building a Pyramid Generator - Step 55

Tell us what’s happening:

can you tell what is wrong with my code? ive tried everything

Your code so far

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

function padRow(name) {
  return name;
}

// User Editable Region

function addTwoNumbers(x,y){
  const x = 5;
  const y = 10;
  const sum = addTwoNumbers;
return x + y;
}
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 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Mobile Safari/537.36

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 55

The first two lines of the function are overwriting the values given to the function in its arguments. Pls remove these lines.
The third line creates a variable sum but it tries to assign another variable to it called addTwoNumbers which doesn’t exist. (Check the console and you should see an error message about that)
Only the final return statement is correct.

1 Like

Hi there and welcome to our community!

You shouldn’t try to explicitly set the values of x and y. Your function should simply return the sum of whichever values are supplied as arguments to the function, when it is called. Your return statement is correct but you can lose the other three lines of code, as they are redundant.

Still no use, this code is also not working, it’s throwing an error in the console.

If you have a question about your own code, please ask about it in your own topic.

i got it right thanks for the clues :))

1 Like

i got the answer ur answer help a lot thanks

1 Like

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