Learn Introductory JavaScript by Building a Pyramid Generator - Step 55

Tell us what’s happening:

I’m going crazy, I can’t figure out what my issue is.

Your code so far

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

function padRow(name) {
  return name;
}

// User Editable Region

function addTwoNumbers(firstNumber, lastNumber) {
  var sum = firstNumber + lastNumber;
  console.log(sum);
}

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 (X11; CrOS x86_64 14541.0.0) 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

Your function should return the sum of the two numbers.

How do you return a value?

I’m not sure, I thought what I did was right, and it seems to work. I checked it out by substituting different values in and it was consistently giving me the right answer, I just don’t understand what I’m doing wrong.

I think you might want to return sum within your code block!

const addNum = (num1, num2) => {
 return num1 + num2;
}
console.log(addNum(4, 3)) ;//expected output: 7

Thanks for the reply, I actually managed to pass the step but I still don’t quite understand why my code was wrong. I know I was supposed to use return, but I don’t know what that changes. If I was actually just writing this as code rather than trying to pass the steps would my code work?

Your code could’v work, but you was going to get undefined and I am not quite sure, if that was the output you would’ve anticipated. You can read more about function scope here : Functions - JavaScript | MDN