100 Days of Code, Day 8:

20 June 2017

tiff
100 Days Of Code

--

Today’s Progress:

Learned about the many quirks of JavaScript, including, but not limited to type coercion (which I already knew about and much more than this course has taught thanks to JavaScript Understanding the Weird Parts) and NaN == NaN. Which is super weird.

We wrote a few while loops. I was cruising along with three of them and then the fourth one I wrote I made the browser crash. Code will be posted below.

I also got a glimpse into the difference between Number and parseInt for converting strings to numbers. parseInt parses strings up to the first floating point number while Number actually coerces the string into a number. For instance:

Suppose the user guesses “5”. Number will coerce a string, say "5", into 5. If a user types "5 or 6", Number will spit back NaN because it cannot coerce the string.

Say a user types “5pt” in this scenario. parseInt will parse the string looking for the number and exclude any letters in its return. Number seems to be more performant, depending on what you want to do.

Thoughts:

Getting into some meatier stuff.

Link to work:

Here is the repo.

Gist:

--

--

tiff
100 Days Of Code

Recovering web dev degenerate. Home labber and cybersecurity hopeful. Write at: https://tifflabs.org and https://0x8c.org