guest@r4mzy.co.za — bash~/blog

# session · resolving peer…

guest@r4mzy.co.za:~/blog$

less — ~/blog/roping-rocks-and-snipping-pa.md

Roping rocks and snipping paper with Codecadamy


So for the last two weeks or so I have been monkeying about with injecting some coding knowledge into my skill set (or something…). This has primarily been through the Stanford CS106A (Programming Methodology) course and lectures on Udemy/YouTube, and resuming my long-abandoned and meagre progress on Codecademy. I spent an inordinate amount of time fiddling with the Rock, Paper, Scissors exercise on the latter’s JavaScript track, and because I want to feel like it was worthwhile I’m dropping it here, after the jump.

Right then. I’ve no clue if this stuff depends on any particular libraries being present on the system running it or anything like that, I’m just copying the code right out of the Codecademy editor and sticking it here. Hurrah! If anyone reading this knows a thing or two about JavaScript or programming in general (or even if you know nothing at all, it’s cool), do let me know what you think of my scratchings. ^^

` // declare global user and computer choice vars var userChoice = null; var computerChoice = null;

// make your picks var makeChoices = function () { userChoice = prompt(“Do you choose rock, paper or scissors? Or perhaps you’ll hang yourself with a rope…”).toLowerCase(); computerChoice = Math.random(); if (computerChoice The game seems to play fine, as far as I’ve tested. It does feel a little nuts to have written 100 lines of code for something so simple, but I guess in the grand scheme of things that’s pretty tiny. Not to mention all the extra space that all the best-practice spacing takes up.

If you’d actually like to try the code out, this Codecademy link will take you straight to the relevant exercise page. Once there, just copy my code above and stick it into the editor.

← blog