Numbers, Strings and Boolean...Oh My!
Ok, so far I've learned a few Javascript types. Numbers are pretty self explanatory , and strings are just text. "It\'s good stuff". (Yeah, I'm at the beginners beginners level.)
Boolean reminds me of binary numbers, which is cool. It's either true or false, on or off, a 1 or a 0.
Comparisons are interesting.
true !== true = false
Oddly enough that makes sense to me. Now, remainder/modulo operators on the other hand...umm. Maybe it's because math was never my strongest suite, but that one right there has me a little confused. For example, I know 12 % 5 creates a remainder of 2, but I don't quite understand how we got there. Definitely an area where I'll need to do a little more studying.
Top comments (3)
You can think of modulo like so.
where floor means round down
More generic example
So let's do a random one
34 % 14
I don't know if this helps or not 🙂
Wow! I've been going through Stack Overflow and MDN trying to find deeper explanations on this and so far yours is the best breakdown I've seen. The way you explained it definitely makes more sense. So using another example via your method..
26 % 8 = x
26 - (floor(26/8) * 8 = x
26 - (floor(3.25) * 8 = x
26 - (3 * 8) = x
26 - 24 = 2
Is that correct?
Thank you so much for your help!
Yep that's correct, well done 🙂
Glad I could help.