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
I don't understand what is the problem, looks fine to me
why do u have literally everything in an async await function
also whats the point of IIFE if your whole code is in it
If my code is outside the IIFE, the sync functions will by default fire before the async functions which isnt what I want.
ya well your code is very hard to understabd
Which part are you have trouble with so I can explain
the whole code is kinda hard to understand
Why
lack of comments plus everything is in 1 single place
Okay imma comment it
k
I added comments to the code. Could you check?
the codepen dosnt show any comment
Oh
I updated just on github
J a minute
Updated on codepen
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
GitHub
weather_app/srcipt.js at master · glutonium69/weather_app
A web application that tells weather forecast in different places - glutonium69/weather_app
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
generateGrid is not async function anymore
didn't notice but u get what i mean