Apr 21, 2017
So this software development malarkey has just gone up a notch or 6! It’s been a couple of months since I’ve chucked up an update on where I am at so I thought it was about time to confirm that I have not given up but I have dropped a couple of gears to try and get my head around JavaScript.
As a virgin coder who is trying to fly solo, JavaScript is definitely starting to put me through my paces. I know I’ll eventually get my head around Loops, Arrays, Variables, if statements and all of the other joys that JavaScript offers.
Where am I at with JavaScript?
The biggest achievement so far has been to create a “random number generator” in which the code prompts the system to emulate a random number between 1-5 and then allows the user to attempt to guess the number. Depending on if the guess entered is correct or not the system will then chuck back a different alert stating if the user was correct and if not what the correct number was.
So how it works is the user whacks in a number between 1-5 into an input text box (id – “guess-entered”) and then by hitting the button (id – “guess-button”) coded in HTML the JavaScript will then compute a random number simply by the command Math.random and send back an alert to the page.
The alert will vary depending on if you guess correctly or not. If the user gets it right then it would alert “Well done you got it!” and if they don’t it will spit an alert back stating “Nope! The random number was 1” with the number changing accordingly.
To make that happen I created a variable (var – randomNumber) which would identify what the random number generated was and will alert “Nope! The number was – “randomNumber” to show that each time a different number is being emulated.
How long did it take me?
In total it took me 3 weeks to figure it all out and the code is below so feel free to pick it apart on how it could be improved. It’s also worth noting that I never got around to adding any styling to it as I was over the moon with the fact that I got it to work which means the thing is very basic on the eye but does the job.
I’ve also upgraded myself from Notepadd++ to Visual Studio code after a recommendation from a friend. I need to dig into it a bit more but if anyone can share some of the features that I can make the most of that would be appreciated because at the moment I’m not sure that I am getting the best out of it!
Tackling JavaScript has really opened my eyes to how mathematical and algorithmic coding can be and I see why it’s addictive as there was a massive sense of achievement when I finally got the bloody thing to work. Even though it’s early days I can see that the possibilities are endless with what you can great and there is so much to learn.
So what’s next?
I think I’ll keep my head down for a while with the basics of JavaScript, but I’ve already lined up a couple of courses in the Angular.js & React.js Frameworks to understand what all the fuss is about!