Is there another way to do this?

I want to generate a random word, when the users enter the site I want it to generate a random word, then generate the grid. The way I thought to do this was to use an IIFE asynchronous, but it takes a few milliseconds to generate the first grid. Code: https://github.com/LeonCelestino/Wordle-Game/blob/main/assets/scripts/index.js Livesite: https://codepen.io/leoncelestino/pen/wvObBax
GitHub
Wordle-Game/assets/scripts/index.js at main · LeonCelestino/Wordle-...
A wordle game. Contribute to LeonCelestino/Wordle-Game development by creating an account on GitHub.
18 Replies
Giustomuh
Giustomuh10mo ago
I don't understand what is the problem, looks fine to me
glutonium
glutonium10mo ago
why do u have literally everything in an async await function also whats the point of IIFE if your whole code is in it
Pi, a future fluent jp speaker
If my code is outside the IIFE, the sync functions will by default fire before the async functions which isnt what I want.
glutonium
glutonium10mo ago
ya well your code is very hard to understabd
Pi, a future fluent jp speaker
Which part are you have trouble with so I can explain
glutonium
glutonium10mo ago
the whole code is kinda hard to understand
glutonium
glutonium10mo ago
lack of comments plus everything is in 1 single place
Pi, a future fluent jp speaker
Okay imma comment it
glutonium
glutonium10mo ago
k
Pi, a future fluent jp speaker
I added comments to the code. Could you check?
glutonium
glutonium10mo ago
the codepen dosnt show any comment
Pi, a future fluent jp speaker
Oh I updated just on github J a minute Updated on codepen
glutonium
glutonium10mo ago
well the way u did it certainly is 1 way to do but there are a lot of things that u can improve such as , u have functions like generateGrid that has nothing in it that needs to be done asynchronously yet u r defining it as asynchronous, u have functions to update the amount of tries and another similar function that r just not needed, u can just simply define a global variable here and increment it on each try. you can improve the structure of your code by a lot. and prolly some more improvement here and there overall, you code works fine ya, but it's definitely not the best way to write your code
glutonium
glutonium10mo ago
GitHub
weather_app/srcipt.js at master · glutonium69/weather_app
A web application that tells weather forecast in different places - glutonium69/weather_app
glutonium
glutonium10mo ago
this a code i wrote a long ago trying to make a wreather app you can check how each set of statements r isolated in their own function by no mean the piece of code i wrote is THE BEST , but you can take idea from it
Pi, a future fluent jp speaker
generateGrid is not async function anymore
No description
glutonium
glutonium10mo ago
didn't notice but u get what i mean
Want results from more Discord servers?
Add your server