Learn Introductory JavaScript by Building a Pyramid Generator - Step 54

Tell us what’s happening:

function addTwoNumbers(num1, num2){
return sum(5 + 10);
};
const sum = (5 + 10);
console.log(sum);

above is my code still showing error showing that function should return the sum of the two numbers

Your code so far

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

function padRow(name) {
  return name;
}

// User Editable Region

function addTwoNumbers(num1, num2){
  return sum(5 + 10);
};
const sum = (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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 54

  1. what is this ‘sum’ thing you’re declaring? + adds two numbers together

  2. you are not using the function arguments

Your console log is good.
Your sum variable to assign the value of calling “addTwoNumbers” is wrong. Look at that again after =.

In your function you have declared parameters / arguments,. In the return value you need to use them (not numbers) to achieve what the question asked.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.