Hey everyone! I'm a coding newbie and currently learning through freeCodeAcademy. I'm stuck on an exercise where I'm supposed to replace a log statement with a command to push the variable `i` to my `rows` array. Here's what I have so far:
```javascript
const character = "#";
const count = 8;
const rows = [];
for (let i = 0; i < count; i = i + 1) {
console.log(i);
}
```
I thought to replace `console.log(i)` with `rows.push(i)`, but I'm getting an error saying that I should call `.push()` on my `rows` array. I also tried to put `rows.push(i)` directly after `const rows = []`, which gave me a TypeError about reading properties of undefined. I even attempted placing it in the for loop as `for (let i = 0; i < count; i = i + 1; rows.push(i))`, but that didn't work either.
Can anyone help me understand what I'm missing? Thanks!
2 Answers
Just to add on, it looks like your issue might be related to how you're calling `push`. Avoid putting a space between `rows.push` and the parentheses. So it should be `rows.push(i)` without a space. Those little details can sometimes trip you up! Let me know how it goes.
You're on the right track! Just make sure to replace `console.log(i)` with `rows.push(i)` inside your for loop as you've planned. It should look like this:
```javascript
for (let i = 0; i < count; i = i + 1) {
rows.push(i);
}
```
That way, `i` will be pushed to the `rows` array in each iteration. Give it another shot!

Related Questions
How To: Running Codex CLI on Windows with Azure OpenAI
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically