Learn Introductory JavaScript by Building a Pyramid Generator - Step 55

Tell us what’s happening:

Hello All,

I am pretty confident that I have the function written out correctly, however, the error message tells me that I am returning a “hard-coded value”. I may not have a correct understanding of this.

Your code so far

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

function padRow(name) {
  return name;
}

// User Editable Region

function addTwoNumbers(num1, num2) {
  
  num1 = 5;
  num2 = 10;
  let sum = num1 + num2; 
  return 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/127.0.0.0 Safari/537.36

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 55

You overwrote num1 and num2 so these are the only two possible inputs for the function. You should use the values passed in as function arguments instead of overwriting those values.

I’m not sure I’m following. When change num1 and num2 two 5 and 10, I keep getting errors as well…

Why are you changing num1 and num2 inside of your function?

So they’re not “hard-coded”. Should that be outside of the {}?

You are hard coding them by forcing num1 and num2 to only use one specific value inside of your function.

function addTwoNumbers(5, 10) {

let sum = 5 + 10;
return sum;

Also, thank you for helping me! This one has me super stumped

1 Like

Now you aren’t using num1 or num2 two at all and are using numbers that cannot be changed. That’s the opposite direction than you want to go.

Back up and think why I would ask this:

1 Like

Got it! OMG! It was a journey lol :joy:
Thank you!

1 Like

Nice work figuring it out!

1 Like