Hey, the Box tells me that i have to assign sum the value. But imo i gave sum a value with sum = a+b;
i tried to declare it inside the function, but than he is telling me, that i have to declare a sum variable.
i also tried to include the sum = a+b to return sum = a+b. but it doesnt fix the problem. can you help me?
Your code so far
const character = "#";
const count = 8;
const rows = [];
function padRow(name) {
return name;
}
// User Editable Region
let sum = 0;
function addTwoNumbers(a,b){
sum = a + b;
return 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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36
Challenge Information:
Learn Introductory JavaScript by Building a Pyramid Generator - Step 55
this is your function, do not use variables declared outside the function. If you want to use a variable inside the function, declare it inside the function
yes, you need a sum variable outside the function too, but it must not be the one changed by the function, you need to assign a function call to this one instead
Think about this line. What does it do? Where does the value returned by the function go? What if you wanted to use the sum later in the program or print it?
it gives the value 5 to parameter a and 10 to parameter b? The Value is saved in sum? But sum is just inside the function and it cant be used outside the function? Do i have to use sum if call the function?