More JavaScript Practice
I got to use Regular Expressions today!
For those that don’t know what these are, Regular Expressions allow you to display data in a certain way. Some of them were typed very carefully since I didn’t want to copy it from the answer, but it was given to me at the end of the exercise so I could format a population number with commas. And some were very easy since it was just two letters vs something like this: /\B(?=(\d{3})+(?!\d))/g (what I used to get commas to show up on screen.
The was used in an exercise to display a dropdown with city or state names that highlight the parts of the search term. I got a quick explaination on Promises in JavaScript and how to convert a “blob” of data that is returned in the promise into JSON that can be worked with in the code. I also got to use fetch() without the need of a library or framework since fetch() is built into the browser now.
So this exercise ended up being covered in comments since I know I won’t be able to remember what everything does if I ever go back to look at my code later on. But I do enjoy working with JSON data and looking at different ways to display the data to the user. I may end up using something like this in a project later on since it’s a pretty cool and interesting result on screen.
That’s a pretty neat effect to display data as you type.
That was all I was able to fit in for my JavaScript practice today. I’ll more later on this week.
Until then, happy coding! 👩💻