Learn Introductory JavaScript by Building a Pyramid Generator - Step 54

Tell us what’s happening:

function addTwoNumbers( sumOne, numOne) {
return sumOne;
return numOne;
}
let sum = addTwoNumbers(5 , 10);
console.log(sum);

I don’t get what I am supposed to do here , I’ve defined the two argument , returned them but I can’t see what I am doing wrong.
(Note : it keeps saying “Your function should return the sum of the two numbers” as an error.)
link = https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures-v8/learn-introductory-javascript-by-building-a-pyramid-generator/step-54

Your code so far

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

function padRow(name) {
  return name;
}

// User Editable Region

function addTwoNumbers( sumOne, numOne) {
  return sumOne;
  return numOne;
}
let 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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 54

This function does not return the sum of two numbers.
Firstly, you should only have one return statement in your function.
Secondly, it should return the result of adding your two values together.

Your function is returning the value of the first argument (sumOne).
If you call sumTwoNumbers(5, 10), the output will be 5.
(The second return statement is redundant as the function terminates with the first return statement).

First of all you can only have one return statement. You need to return the sum of the two parameters (in your case sumOne + numOne)

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