Tell us what’s happening:
you should call .repeat() on your two " " strings
Your code so far
function padRow(rowNumber, rowCount) {
return rowCount-rowNumber.repeat() + character.repeat(rowNumber) + rowCount-rowNumber.repeat();
}
const character = "#";
const count = 8;
const rows = [];
// User Editable Region
function padRow(rowNumber, rowCount) {
const spaces = "·".repeat(rowCount - rowNumber);
return spaces + character.repeat(rowNumber * 2 - 1) + spaces;
}
// User Editable Region
for (let i = 0; i < count; i = i + 1) {
rows.push(padRow(i + 1, count));
}
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/124.0.0.0 Safari/537.36
Challenge Information:
Learn Introductory JavaScript by Building a Pyramid Generator - Step 62
Learn to Code — For Free
Hi @rautraokailas17 !
Welcome to the forum!
Your issue is here
rautraokailas17:
"·".repeat
the directions say to use repeat on your spaces.
not a string with a dot in it
But also, with the current tests, it doesn’t account for creating a variable like this
For passing the tests right now, I would suggest resetting the lesson and modifying this line directly without creating any variables
return " " + character.repeat(rowNumber) + " ";
also, I have created an issue for this since there are multiple correct answers for this
opened 11:53AM - 23 Apr 24 UTC
type: bug
scope: curriculum
first timers only
new javascript course
### Describe the Issue
A camper on the forum was trying to pass this step with … the following code:
https://forum.freecodecamp.org/t/learn-introductory-javascript-by-building-a-pyramid-generator-step-62/686710
```js
function padRow(rowNumber, rowCount) {
const spaces = "·".repeat(rowCount - rowNumber);
return spaces + character.repeat(rowNumber * 2 - 1) + spaces;
}
```
Their issue was that they shouldn't have the `"."` but instead us an empty space `" "` like the directions say.
With the correct modications, this is a valid answer
```js
function padRow(rowNumber, rowCount) {
const spaces = " ".repeat(rowCount - rowNumber);
return spaces + character.repeat(rowNumber * 2 - 1) + spaces;
}
```
but with the current tests, it would fail because we are checking for `" ".repeat(rowCount - rowNumber)` twice.
```js
assert.lengthOf(code.match(/" ".repeat/g), 2);
```
either valid answer should pass
## valid answers
```js
function padRow(rowNumber, rowCount) {
const spaces = " ".repeat(rowCount - rowNumber);
return spaces + character.repeat(rowNumber * 2 - 1) + spaces;
}
```
or
```js
function padRow(rowNumber, rowCount) {
return " ".repeat(rowCount - rowNumber) + character.repeat(rowNumber) + " ".repeat(rowCount - rowNumber);
}
```
## updates to tests
remove this test completely
````md
You should call .repeat() on your two " " strings.
```js
assert.lengthOf(code.match(/" ".repeat/g), 2);
```
````
And instead just have one test for the final result.
This way multiple answer pass
here is the updated test
````md
You should call `.repeat()` on your `" "` strings to repeat them `rowCount - rowNumber` times.
```js
assert.equal(padRow(1, 3), " # ");
```
````
### Affected Page
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures-v8/learn-introductory-javascript-by-building-a-pyramid-generator/step-62
### Your code
see explanation above
### Expected behavior
see explanation above
### Screenshots
_No response_
### System
- Device: [e.g. iPhone 6, Laptop]
- OS: [e.g. iOS 14, Windows 10, Ubuntu 20.04]
- Browser: [e.g. Chrome, Safari]
- Version: [e.g. 22]
### Additional context
_No response_