I have just finished my Local Weather challenge. I will be glad if someone could give a feedback for me.
I used the following things to do this challenge:
- LocalStorage .getItem() and .setItem()
- Number .isInteger() and .toFixed()
- JSON .parse() and .stringify()
- parseInt() and parseFloat()
- Mobile First
- mixin to create toggle button
- mixin to create loader
- animation (for loader)
- selectors :first-child and :last-child
- display Grid
- background position technique
He’s using only jquery . i’dont see any arrow functions in his js code.
As for the dom queries you are right. @carlostahira you should try caching your dom like
var title = $('.weather__title'); and use the vars
ES6 variable syntax would be better though
Hello @borisyordanov @sorinr.
First of all, thanks for your feedbacks and sorry for delay. I refactored my challenge, check again if you could.
Yes, I have been studying only vanilla and I realized that I need to practice a little of jQuery, so I seized the opportunity to do it.
Yeah, thanks for recomendation. I have already changed the code. Please, check my challenge again if possible
Except pieces of code where I did DOM queries I did not find other variables where the better choice is to become them global and give up encapsulation. Can you show me the exact part of my code to do it if still exists?
On previous block’s code I put a comment line before to explain it. I just tried to keep this pattern. But you are right, in that case was so obvious.
I realize that navigator geolocation is too slow and I solve it using localStorage:
- First I check if there are coordinates stored. If true, I immediately run my code to show the result
- For all request I always get geolocation’s user, around it and and compare with old coordinates.
- If the coordinates are different, save new coordinates and run the code again.
So, it solve 2 problems:
- High load time to show the weather condition for user. It will be slow only on the first time
- Update weather condition values automatically if the user changed location compared the last time he visited the page (a user visited the page, close the notebook, moved to other country and revisited the page)