Friday, January 6, 2017

JS30 Challenge Day6 - Type ahead (Difficult)


Disclaimer: For this project, I did a ton of copy-paste. Maybe I should revisit this project later for study.

transform: perspective(100px);
Sets the z=0 plane further behind, by the given value

background: linear-gradient(to bottom, white 0%, black 100%);
The % in linear gradient means that that color should reach its full hue by that location in the gradient.

fetch(url);
We used this command in combination with the 'then' property to retrieve the json data from the given city-state website.

'…' is spread. It is used to spread all arguments passed to the array as their own elements

How to put a variable into regular expression
const regex = new RegExp(wordToMatch, ‘gi’);
where g is for global
and i is for case insensitive
wordToMatch is our variable
Then do element.match(regex) or element.replace(regex)

We use filter because we want to apply a function to every single element in the array

'change' can also be an event in addEventListener
Especially handy for inputs
The change event only fires when you step outside that input
So it's a good idea to tie the element up with the 'keyup' event as well

No comments:

Post a Comment