Advertisement

Can you review my code and tell me ways to improve?

Started by August 06, 2022 12:00 PM
2 comments, last by Geri 2 years, 2 months ago

I am doing an HTML/JS project to make a small RPG game in one html file. I will post my github repo link here to the index file. I would really appreciate if anyone who is familiar with javascript to look at my code organization and how I'm writing it and tell me if i'm doing any things wrong or ineffectively. I know about spaghetti code so I try not to do that. I also know not to clump everything together too much or use bad conventions, but it would be quite helpful to get the opinion of someone more experienced on my work. This project is kind of the epitome of about 4 years of studying/working now so it's the most complex thing with moving parts that I've made.

https://github.com/gitWize1/Legend-and-Myth

(the file is "index.html" in the main folder)

No, license file is missing and without it it's illegal to even look at the code

Advertisement

I think your code is a little bit hacky.

let userInput

eleInput.addEventListener('keyup', (event) => {

if (event.key === 'Enter' & eleInput.value != '') {

I think you should write code that is easily portable between languages and platforms, even if this particular code is meant to be javascript only. Your code is FAR better than what most javascript people write! But it could be better. For example the key really should be keycode and not a magic value which can contain strings or random objects, thats a very scriptkiddie method to deal with code. Of course a javascript var can contain anything - but that doesn't means it should, especially if we are dealing with gamedev, when potentially you will end up to write speed-critic code. My hint for now is: the cancer that interacts with the browser, inout, output, must be totally separated from the ACTUAL code to begin with.

This topic is closed to new replies.

Advertisement