Intro to JavaScript and first video.

Hello again! So it’s been two weeks instead of one, but we’ll just move past that. Since my last update, I’ve recorded/edited/uploaded my first video (click here to check it out!) and have spent a lot of time learning the basics of JavaScript. I haven’t spent as much time doing the official GA pre-work, but rather the majority of my time has been spent working in Codecademy on their JS course.

Making the video was a great learning experience. I had never done anything like it and it was rewarding to have a finished product that I was willing to show to friends and family (and maybe some strangers?) I’m actually really looking forward to creating a new video with some of the advice I’ve been given! It definitely seems like one of those things that will get exponentially easier as I get further along with it. So look for that later this week!

Back to actual programming… I’ve really enjoyed the JS intro so far. It feels like things are taught in a well thought out order and each lesson really builds on the previous ones. This is great for a few reasons. You’re constantly reusing the basic ideas and once you learn a new skill, they make you use it in conjunction with the other skills you’ve already learned. From an educational standpoint, this makes sense because you’re driving home the foundational skills while also learning how to implement them in increasingly complex ways. Compare this to just learning individual skills on their own but having no idea how to blend them into a more complete project and it’s easy to see the benefits.

Another thing that I’ve really enjoyed doing is trying to make sense of code and predict the outcome before it happens. It’s been a fun challenge to try and read through other little projects and follow along. This has also had the added benefit of helping me realize how important it is to follow some of the best coding practices: logical variable names, good formatting, informative and concise comments, etc. Well written code seems like it should be easily read and understood.

At the bottom of the post is a copy of the code I wrote for a simple Rock Paper Scissors game. The code might be a bit buggy and/or incomplete (kind of ironic to type that given how I just gushed about properly written code!) I had a more basic version that worked completely, but I tried adding some other features that aren’t completely working yet. I don’t mind having my incomplete or glitchy code on here, I actually kind of like it. I am really looking forward to going back in a few weeks and seeing if I can fix up this project and make it a bit more user friendly. I also really like the idea of having a record of the early things I created and seeing my progress.

One thing I tried adding on my own was a prompt for the user to pick a new option if they picked something that wasn’t “rock,” “paper,” or “scissors.” The original game didn’t do anything special if the user wrote something like “dog.” I added in a line that gives a feedback message if they pick something that shouldn’t work, but I’d like to add more functionality that not only tells them they messed up, but also asks them for a new input.

My guess is I’d go with a while loop? Something like

while(choice1 !== “rock” || choice1 !== “paper” || choice1 !== “scissors”){
var userChoice = prompt(“That was not a correct choice. Please pick either rock, paper, or scissors.”);

I’m not sure if that’d work, I’ll try it out a bit later! When I originally created this program in Codecademy, we hadn’t yet learned about loops yet. So if you look at my code at the bottom, I tried to use some if statements to make it work. What do you think is the best way to tackle this problem?

For those of you that don’t know code but read this far, can you figure out what it would say if someone chose “dog?”

That’s all for today! As always, I’d love any feedback or thoughts! My code for Rock Paper Scissor is below.  Until next time..

var userChoice = prompt(“Do you choose rock, paper or scissors?”);
var computerChoice = Math.random();
if (computerChoice < 0.34) {
computerChoice = “rock”;
} else if(computerChoice <= 0.67) {
computerChoice = “paper”;
} else {
computerChoice = “scissors”;
} console.log(“Computer: ” + computerChoice);

var compare = function(choice1, choice2) {
if(choice1 !== “rock” || choice1 !== “paper” || choice1 !== “scissors”){
console.log(“You’re an idiot.”)
if(choice1 === choice2) {
userChoice = prompt(“It was a tie! Pick a new choice!”);
computerChoice = Math.random();
compare(userChoice, computerChoice);
else if(choice1 === “rock”){
if(choice2 === “scissors”){
return “rock wins.”;
return “paper wins.”;
else if(choice1 === “paper”) {
if(choice2 === “rock”){
return “Paper wins”;
return “scissors wins”;
else if(choice1 === “scissors”) {
if(choice2 === “rock”){
return “rock wins”;
return “scissors wins”;

compare(userChoice, computerChoice);



  1. lethallysharpenedquill

    Good to see you’re enjoying it! I’ve only been coding in Java, though, since when I took my first computer science course in Java, and I am currently in my first year of my computer science degree, although still in Java! I’ve gotten a bit bored of it and decided to start to expand my programming knowledge and thought that web development would be a nice change of pace. I’m starting Codeacademy’s course on HTML/CSS as I write this, and I’ll probably follow that up with Ruby or Javascript.

    So although I’m not entirely new to programming, web development is rather alien to me. So I guess I’m coming along on this journey too! Good luck to you on whatever you happen to be doing next!

    • Awesome to hear! I really enjoyed Codecademy’s HTML/CSS course. I think my plan is to finish up the JavaScript course and then check out Ruby as well. Let me know how you enjoyed the HTML/CSS course and if you check out any other resources.

      I’ll be going to a programming bootcamp starting February 16th, so I’m pretty excited for that! I’m hoping it’s a bit more fun and engaging than your comp sci class you wrote about on your blog!

      Good luck to you too!

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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

%d bloggers like this: