Learn Introductory JavaScript by Building a Pyramid Generator - Step 55

Tell us what’s happening:

its telling me my sum should be 15 but from what iv learned my sum should equal mu function and i set the function to add but when i try to log it is not correct

Your code so far

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

function padRow(name) {
  return name;
}

// User Editable Region

function addTwoNumbers(a, b){
 return (a + b) 
}
let sum = addTwoNumbers();
addTwoNumbers(5, 10);
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 + row + "\n";
}

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/128.0.0.0 Safari/537.36 OPR/114.0.0.0

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 55

2 Likes

as you are calling the function without arguments, it cannot output 15

1 Like

am i not doing that on the line after that, or is that an improper way to do that?

the other function call is not assigned to anything, its output is not saved in any variable. The tests are checking the value of sum, not those of function calls not saved anywhere

so the addTwoNumbers() function call is not saved as the function itself? i assumed when i set sum to equal that function it would make like an opened ended question and i could just put in whatever 2 numbers i wanted after the fact to get the addition of the 2.

sorry, just trying to understand the functionality of the system.

When you write

you are saving into sum that specific function call, in this case it would be the result of undefined + undefined.
If you call the function again, it’s a different function call

code is executed line by line top to bottom

You could use something like this tool to see the execution step by step: Online JavaScript Compiler, Visual Debugger, and AI Tutor - Learn JavaScript programming by visualizing code

1 Like

okay, thank you very much. that makes sense. i didn’t realize it specified that specific.