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
Giustomuh4mo ago
I don't understand what is the problem, looks fine to me
glutonium
glutonium4mo 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 (I'll eat who dont correct me
If my code is outside the IIFE, the sync functions will by default fire before the async functions which isnt what I want.
glutonium
glutonium4mo ago
ya well your code is very hard to understabd
Pi (I'll eat who dont correct me
Which part are you have trouble with so I can explain
glutonium
glutonium4mo ago
the whole code is kinda hard to understand
glutonium
glutonium4mo ago
lack of comments plus everything is in 1 single place
Pi (I'll eat who dont correct me
Okay imma comment it
glutonium
glutonium4mo ago
k
Pi (I'll eat who dont correct me
I added comments to the code. Could you check?
glutonium
glutonium4mo ago
the codepen dosnt show any comment
Pi (I'll eat who dont correct me
Oh I updated just on github J a minute Updated on codepen
glutonium
glutonium4mo 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
glutonium4mo 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
glutonium4mo 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 (I'll eat who dont correct me
generateGrid is not async function anymore
No description
glutonium
glutonium4mo ago
didn't notice but u get what i mean
Want results from more Discord servers?
Add your server
More Posts