Files

1.6 KiB

id, title, challengeType, dashedName
id title challengeType dashedName
660f2fbd45b520046cac68e8 Step 65 1 step-65

--description--

Remember in an earlier step, you learned about return values. A function can return a value for your application to consume separately.

In a function, the return keyword is used to specify a return value. For example, this function would return the value given to the first parameter:

function name(parameter) {
  return parameter;
}

Use the return keyword to return the value of the character variable, repeated rowNumber times.

--hints--

You should use the .repeat() method.

assert.lengthOf(__helpers.removeJSComments(code).match(/\.repeat\(/g), 2);

You should use the .repeat() method on your character variable.

assert.lengthOf(__helpers.removeJSComments(code).match(/character\.repeat\(/g), 2);

You should pass rowNumber to your .repeat() call.

assert.match(__helpers.removeJSComments(code), /character\.repeat\(\s*rowNumber\s*\)/);

You should use the return keyword.

assert.match(__helpers.removeJSComments(code), /return/);

You should return the result of your .repeat() call.

assert.equal(padRow(3), "###");

--seed--

--seed-contents--

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

--fcc-editable-region--
function padRow(rowNumber, rowCount) {

}
--fcc-editable-region--


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);