My code returned the sum of the two numbers, but it said it’s hardcoded. Please help
Your code so far
const character = "#";
const count = 8;
const rows = [];
function padRow(name) {
return name;
// User Editable Region
}
function addTwoNumbers(sum) {
return sum;
}
const sum = 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 + "\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
Hey there,
This is a tricky one. It’s worded pretty poorly imo and so you could code it many ways to get the desired outcome (sum=15), but it only accepts 1 method. Even going back to this (finished it weeks ago) again, it took a little while to find the right answer.
The first thing is, which has already been pointed out, is your function needs two paramters, which are the variables inside the brackets(). You have one, called sum. I would actually not name either of the parameters sum to avoid confusion. Call your parameters any other thing you want, but just use letters and no spaces. Seperate with a comma. Example: function howdy(train, dude)
The next problem is in this code const sum = addTwoNumbers(5 + 10). You may think you are passing two arguments to this function call, but you are actually only passing one. The arguments need to be seperated with a comma. Right now, the code is just interpreting a single argument of 15.
At this point all you are missing is the logic that performs the math. I will leave it to you to figure out where that goes and what it looks like (hint: it’ll use your parameters as variables, no numbers involved).
welcome to JS
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.
do this step by step
create function
pass arguments two arguments as your wishes like english alphabet
return and do sum calculation inside the curly braces
after creating the function
Declare a sum variable assign it the value of calling your addTwoNumbers function with 5 and 10 as the arguments
finally log it in the console
this is the way to understand the concept