Skip to content
Sign upLog in
← Back to Community

Will someone review the index.js of my repl.it and show me what I've done wrong or omitted?

Profile icon
donahuejason

https://repl.it/@donahuejason/return-of-fizz-buzz

Goal: to enter a positive number in the box created in HTML, then have results populated based on if that number is divisible by 3, 5, both, or neither.

My goal: to learn about what's not working and how to fix it. I do not want someone to "just fix it" for me.

Background: This is a drill for a lesson in a course I'm taking, and the focus of the drill is to teach event loops and jQuery. I know my javaScript often needs work, too.

Ask: Right now, my code doesn't work, and I can't find where I've gone wrong. The HTML and CSS were supplied by the course program, but the javaScript is all mine. I have my notes and other questions commented out in various places. Any help is greatly appreciated. Thank you in advance.

Voters
Profile icon
donahuejason
Comments
hotnewtop
Profile icon
MadgeErnser

You have a lot of unused var statements. The first variable, name, is declared and it's used in the second line, but not in the third or fourth line. This makes it hard for the reader to understand what your code does. It also makes it hard for you to read other people's code and understand how they are using it. Now I have to visit this link in order to know how to make a perfect movie review.

Profile icon
Giothecoder

The problem is none of your code is actually being run. Since it’s all in a function, you have to call the function first. Though I actually would suggest just getting rid of the lines that make it a function and let it run immediately.

Profile icon
RohilPatel

I would add code to determine if they are divisible. Then I would make some if statements stating whether or not to give a innerHTML of "fizz" or "buzz". If they are not divisible, just make the string "". Hope this helped.

Profile icon
RohilPatel

I would have done this an easier way.

Profile icon
Giothecoder

@RohilPatel
well that isn’t very helpful lol.

Profile icon
RohilPatel

Haha, I did another post.

@Giothecoder

Profile icon
Giothecoder

@RohilPatel
oh lol, I was like "where..?"

Profile icon
RohilPatel