What I Hated the Least Today 250/365: The Joys of JavaScript

What I Hated the Least Today 250/365: The Joys of JavaScript

A JS Troll Game

Remember how I reported a year and half ago that I was starting to learn <HTML>? Neither do I. But I found the post for you: it was a What-I-Hated-the-Least-Today number 44. Half a year after this, I decided that my immersion into coding was permanent and sealed the deal with a {CSS} tattoo. It was aย Hate-the-Least number 203.

Currently I’m on JavaScript. High on it. It doesn’t need to be assumed that I have meanwhile mastered HTML and CSS, though I did my best. I also dipped into SASS, which is just a sassily named condensed version of CSS. I liked it to start with but then it got too abstract and logical. I know, right. How can I even attempt coding if I have trouble with abstract and logical? Well, *shrug*, I have no idea how come I’m so passionate about something at which I suck so much, but I just am.

Today I had a thrilling JavaScript (JS) revelation. Since I have no one to tell to, I ย need to blog about it. So, have you ever wondered how to make a computer choose a random number, such as in lottery? Me neither. Despite me not wondering and you not really wanting to know, I discovered (as many have before me), that JS can be used to make the computer do this.

In JS, there’s this fascinating function, Math.random(). It doesn’t exactly do what it promises: it does produce a random number, but just between zero and one, and most likely not an integer on top of it. To fix the *not-integer* part, there’s the Math.floor() function to add to it. To fix the *between-zero-and-one* part, you can multiply the number by another number. So, e.g., Math.floor(Math.random() * 5).ย There must be an easier way to do such a simple thing. I’ll report back in several years when I discover it (as many have before me).

Also, don’t get me started about what you can do to random numbers. You can assign them options, for example. If there are two options, you’d use the if/else statement to do something; else you’d use switch, if there are more cases. You don’t need numbers to do if/else or switch, obviously. Today I was practising switching, but since if/elseing is shorter, here’s an if/else if/else. It does nothing in particular, and nothing at all on WordPress, where JS isn’t allowed. It’s just supposed to remind you that you should like code and cats, like I do, because code and cats.

var cat = prompt('Do you like cats? Type YES or NO.').toUpperCase();
if (cat === 'YES') {
} else if (cat === 'NO') {
console.log('We can\'t be friends.');
} else {
console.log('You say what?');

And, finally, here’s my JS-themed recent tweet. Based on actual events.

28 thoughts on “What I Hated the Least Today 250/365: The Joys of JavaScript

  1. I’m so glad I stopped by today and I was an ear and eye to your revelations…sadly I am no where near as smart as you and the whole post, as fascinating as I’m sure it is, was unfortunately lost on me, so I am feeling highly inadequate right now….so I might go and write a post able much simpler things such as mice or horses or dare I..flowers??


    1. I’m so sorry for making you feel inadequate! The idea was the opposite – to show my own inadequacy… I like mice, so please do go and blog about them! Maybe you’ll become a new Robert Burns ๐Ÿ™‚

      Liked by 1 person

  2. Wow, your waaaay ahead of me with coding! JS is so weird. I remember your post about beginning HTML. Hope your well Mara and your bug free! I’ve been ignoring my Twitter account. Instagram is so much more fun.


    1. It’s so nice that you remember my HTML beginnings ๐Ÿ˜€ We’re been around for a quite a while, right!

      JS is the language that has fascinated me the most so far. When you put aside the weird punctuation marks, all the brackets and braces and whatnots, it’s actually readable as normal English. And I love it that I can call my variables and functions whatever I like, such as “cat” ๐Ÿ˜€

      I see that you prefer taking photos to, say, tweeting, and, obviously, I enjoy your photos from your fascinating location!

      Liked by 1 person

      1. Twitter doesn’t feed my photography cravings like Instagram does, I love Instagram. I’ve not bothered with my Twitter account for several days now.

        My site isn’t a Niche’ blog but it does see plenty of photography uploads.

        Java Script is so weird, my experience is mostly with CSS because of the websites I’ve had over the last many years.

        A bit of HTML, I used to make my own Tables for displaying text or photos a long while back. And yes, I’ve been hanging out with you for a few years now.

        If I were closer I’d buy us lunch or dinner!


        1. Instagram is fun for me too because it makes look even my crappy photos somewhat more bearable with the filter options ๐Ÿ˜€

          I don’t think there’s a likelihood of me travelling to the US, but should it happen, I’ll let you know and we’d totally go for coffee or something!


  3. If I hadn’t studied web design, I would have no idea what you’re talking about ๐Ÿ˜€ I hate coding myself and javascript is the most difficult one.


    1. Oh, so cool, you studied web design? That’s what I should have done. If JavaScript is the most difficult, then it’s good news to me, so far, I’m finding it challenging but I’m not completely lost yet! I have no clue why it fascinates me so much.


      1. Yes, gratuated this year. Javascript is complex and a singel fault, it doesn’t work.For me it’s like Maths, I’m bad at it.


  4. HIArthur Clarke Mara. Great post. It reminds me of one of my brothers who gets excited about advanced maths, and tells me all about mandelbrot sets. I don’t have any idea what he’s talking about, but I enjoy it anyway.


    1. Hello Jane, I mean James Joyce, thanks for wandering over to my blog! You’re so right, it’s kind of cute when someone gets excited about some obscure subject that no one but the excited person understands… But it’s only cute for a while before it gets boring. I’m trying not to bore my poor readers to death but sometimes I just can’t help it. Please don’t die ๐Ÿ˜€

      Liked by 1 person

      1. Does it mean I’m sick when I read the words “Please don’t die”, and they make me fall off my chair laughing?
        I can answer that myself. No, it doesn’t. It means I’ve learnt how to be – sort of – well.
        About four years ago I forgot how to laugh. I used to remember how great it felt, and miss it. My niece cured me by taking me to live in a tent in the middle of a wood for six months. ๐Ÿ™‚


        1. I think this means you’re perfectly healthy, not sick ๐Ÿ˜€ I always try to entertain, so it’s my pleasure when it actually works! Kudos to your niece! Kids/young people are so good at being happy. And then we grow up and sometimes lose this survival skill.

          Liked by 1 person

          1. I think it’s because children have the advantage that, however bad things are, the world is new and exciting. When they get older everything seems tarnished. The niece I’m speaking of is 30. She flits across continents at the drop of a hat, takes well paid consultancy work to pay for her voluntary projects, goes rock climbing after a long day, then cycles to the next county and puts up a tent for the night, before cycling home or to a new adventure the next morning. She’s amazing.


  5. I’m learning how to build games during my spare time using Unity.Of course that involves lots of coding – C# specifically. It resembles JavaScript a bit.(Especially with the opening and closing of braces)

    I think coding is both fascinating and tedious. Sometimes you wish things were just there for you to drag and drop and apply functionalities, but you have to create everything…which is the fascinating part.

    Take the first ever Super Mario World,for example,you learn how each and every single thing was implemented into the game: camera follow,enemy movement,end of game level, score count, time left, character movement,etc. I never thought coding was that important. Until today these basics are still being taught.

    C# is challenging but okayish – I don’t have the choice tbh.
    My course was very intense in maths (8 modules per year), and an odd skill I acquired by the end of my 3 years is finding sense in a field of indecipherable symbols and complex calculations. Otherwise I would never make it. That’s how I’m learning right now. That being said there are some lines of coding which make no sense to me still! I was learning Python on youtube, and learned the thing with the dice (how to roll a dice and produce random numbers), but I knew learning a more complex language like C# as a standalone thing would be too boring for me. That’s why I started learning how C# can be used to program games in Unity. Now that I think of it, Python was pretty useful as an introduction to other programming languages.

    Apologies for writing so much!!!


    1. Wow, a fellow self-taught coder! I hugely admire your efforts, it’s not easy to study something on your own and stick to it.

      I checked out Unity and it is for gaming, as you said, so it won’t be my thing. I’d like to develop websites, full stack, preferably, so I’m learning languages appropriate for this purpose. Programming a game must be a completely different thing and fascinating in different ways.

      Writing code can get tedious, but guess what, that’s actually what I like about it. I’m good at routine tasks and since I’m only learning, I like to repeat things to remember them. It’s great that you found a place to learn something in practice, so to say; I’ve learned a lot of stuff already but have limited knowledge of how to apply it, use it for something useful.

      Thank you so much for writing about your experience, it was extremely interesting for me to look at the subject from your perspective!


    1. Yes, it is like Maths – it is Maths, after all – but I won’t let my lack of Maths skills stop me from coding. It’s all a question of practice, as you say. Thanks for stopping by and happy coding!


  6. I really enjoyed your article. I love javascript, too, because I feel like you could do anything with it, if only you knew what to do. You should try jQuery. It’s Javascript, but simplified. They made a bunch of functions for you, so you don’t have to figure out every little detail yourself. Please try my RiddleBot, I made it with Javascript. I’ve only been coding less than a year.


    1. Thank you stopping by and leaving such a nice comment! Yes, I’ve been digging into jQuery a bit too and it looks helpful. Here’s to happy blogging and happy coding then!


Say what?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.