+ 5

[SOLVED] What is the problem with my code?

What is the problem here https://code.sololearn.com/WmeFt4z16CIp/?ref=app

22nd Nov 2017, 3:48 PM
Vaibhav Kushwaha
Vaibhav Kushwaha - avatar
4 odpowiedzi
+ 3
Sorry about delay. Busy day at work. Check out this code and review the HTML/JS tabs, compare it against yours. https://code.sololearn.com/Wj6GOEpHNxKp/#js ^That should help you see some ways to go about what you did more easily. I've fixed the issues, simplified some stuff, and fixed the formatting so it's more readable. Before you form too many habits, I'd take some time to read up on the guidelines for formatting code, from the structure to the naming conventions of variables. When you use single letter variables for everything, it's really hard to distinguish between the variables and what they're each for. It's like if I said "Hello, how are you?" but said it as "H, h a y?" instead. Get what I mean? If you didn't already know that it stood for "Hello, How are you?" then it wouldn't make much sense and you'd have to spend time investigating that. As well, imagine if you returned a long time later to edit code, you'd have to spend time figuring it out again also. Anyways, I hope this helps you out some. Good luck to you! Btw, I learned a lot from the actual function of your code, and I thought it was a pretty cool program once I got it working. I tested various ranges and it appears to be accurate also. Good job on that!!! I've never seen someone calculate that before, so it was fun learning it also. *EDIT/UPDATE* https://code.sololearn.com/Wj6GOEpHNxKp/#js I further simplified the code by doing most of the parsing at the top and storing it in its own variable. Easier on the eyes and easier to type out when you need to use it.
22nd Nov 2017, 5:37 PM
AgentSmith
+ 3
in JS Tab, your code looks like var d= document.getElementById ('q'); //correct var m= document getElementById('r'); //incorrect Put this on one line? document.getElementById('q'); documentgetElementById('r'); You forgot the dot.
22nd Nov 2017, 3:59 PM
AwesomeTGamer
AwesomeTGamer - avatar
+ 3
To be honest, there is a LOT of stuff wrong with it. I'm messing around with it right now and rewriting it. I'll post something up for you within the hour (I'm at work right now).
22nd Nov 2017, 4:10 PM
AgentSmith