Back to Freecodecamp

Step 42

curriculum/challenges/english/blocks/learn-introductory-javascript-by-building-a-pyramid-generator/660f229d2dbe09ef2954a4a1.md

latest1.3 KB
Original Source

--description--

Remember in your previous loop that you used the addition operator + to increase the value of i by 1.

You can do a similar thing with a string value, by appending a new string to an existing string. For example, hello = hello + " World"; would add the string " World" to the existing string stored in the hello variable. This is called <dfn>concatenation</dfn>.

In your for...of loop, use the addition operator to concatenate the row value to the result value.

--hints--

You should use the concatenation operator on your result variable.

js
assert.match(__helpers.removeJSComments(code), /(?:result\s*\+|\+\s*result)/);

You should concatenate row to your result variable.

js
assert.match(__helpers.removeJSComments(code), /result\s*\+\s*row|row\s*\+\s*result/);

You should assign the result of your concatenation back to the result variable.

js
assert.match(__helpers.removeJSComments(code), /result\s*=\s*(result\s*\+\s*row|row\s*\+\s*result);?/);

--seed--

--seed-contents--

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

for (let i = 0; i < count; i = i + 1) {
  rows.push(i);
}

let result = ""

--fcc-editable-region--
for (const row of rows) {

}
--fcc-editable-region--

console.log(result);