mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2025-12-22 03:26:02 -05:00
1.3 KiB
1.3 KiB
id, title, challengeType, dashedName
| id | title | challengeType | dashedName |
|---|---|---|---|
| 6610c71600966a2191d3a64a | Step 59 | 1 | step-59 |
--description--
Values returned out of a function are used by calling the function. You can use the function call directly as the value it returns, or capture the returned value in a variable. This way, you can use the value assigned to a locally scoped variable, outside the function it was created in.
function getName() {
const name = "Camper cat";
return name;
}
console.log(getName()); // "Camper cat"
const capturedReturnValue = getName();
console.log(capturedReturnValue); // "Camper cat"
console.log(name); // reference error
To use your "Testing" value, return it out of the padRow function by updating your return statement to return only the test variable.
--hints--
Your padRow function should return the test variable.
assert.equal(padRow("Naomi"), "Testing");
--seed--
--seed-contents--
const character = "#";
const count = 8;
const rows = [];
--fcc-editable-region--
function padRow(name) {
const test = "Testing";
return character + name;
}
--fcc-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);