##Tell us what’s happening:
I am stuck and I cannot seem to figure this task out. I have put all variables under the function declaration, I have also played with the parametres as well. I am truly stuck…again. PLEASE Help I’m struggling with JavaScript in general so please be kind thank you in advance!
Your code so far
const character = "#";
const count = 8;
const rows = [];
function padRow(name) {
return name;
}
// User Editable Region
let a = 5;
let b = 10;
let sum = addTwoNumbers(a + b);
function addTwoNumbers(a, b) {
return sum
};
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/131.0.0.0 Safari/537.36
Challenge Information:
Learn Introductory JavaScript by Building a Pyramid Generator - Step 55
Hi
Firstly remove the 2 variables at the start. Don’t hard code the values, the function should be able to accept any number.
The task is set out in these 2 paragraphs of the instructions. I suggest you take each paragraph one at a time.
Declare a function named addTwoNumbers
. This function should take two arguments and return the sum of those two arguments.
Declare a sum
variable and assign it the value of calling your addTwoNumbers
function with 5
and 10
as the arguments. Log the sum
variable to the console.
The first paragraph - you have got the function first line right. However I can’t see that you have a function that returns the sum of the 2 arguments. Your code inside the curly braces needs to do this.
Your sum variable is nearly there. Firstly put it after the function. Secondly, check again how you call a function with 2 arguments as the syntax of your code inside brackets is wrong. Also the arguments of a and b are not what is asked for in the second paragraph.
Your console log is correct.
1 Like
Thank you so much! Your answer actually, helped me just by how you worded it differently and such. I appreciate you taking the time to do so! Thank you again.
1 Like
No problem. I’m glad you sorted it out!
1 Like