Prompt User for Name
So I started working on my first goal: Prompt User for name
Even though this was suppose to be the easiest one, I still didn't know where to begin. So I wrote down what exactly I needed in order to prompt user for their name:
The example we got for this was on an onclick the background colour would change from white to red. First we have to create a place to click on the browser that will change the colour when it is clicked. Everything that is seen on our browser needs to be called in the HTML:
<span onclick= "changeBgRed();"> Red</span>
document.bgColor = "red"
<span onload= "getName()"></span>
var name = '';
name = prompt("Hey new friend! What's your name?");
I was freaking out. Nothing like this had happened. To anyone. Ever.
Actually I don’t know that, but I hadn’t seen it before and what started with just repeating my previous line, quickly morphed into a more complex being. It could repeat one line twice on the same line, and it started picking words on its own rather than the entire line. I was panicking- it was learning faster than I was and becoming smarter. As my chat literally began spewing shit at me, my logic finally kicked in: My chat can’t possibly be this smart! I remembered I’d told my friend that I had created this chat and I guess right at the moment it was repaired, and I was typing my stream of consciousness, he got on and was just playing with me.
This was HILARIOUS! I was so tired and had been staring at my computer for over 13 hours. I couldn’t stop laughing, I had been so hyper focused on this script for so long that I wasn’t being logical. When the chat was repeating stuff I was really losing it, in my state of panic I was drawing the most obscene conclusions, and now that I had a minute to breath I realized how insane those thoughts really were. So this practical joke kind of reset my brain and gave me the much needed break I had been putting off for hours.
I finally saw what might be making it so unhappy: I was missing a semicolon at the end of my alert… seriously. So I added in the semicolon, crossed my fingers and refreshed the page…
I yelled, to myself, in my bed at almost 1 am. My victory arms flew up as I watched my first truly successful if/else statement get executed. Relief, satisfaction and pure glee was what I felt. As I came down from this strange high… I realized that I had learned two valuable insights from this long day. First, take breaks, my brain needs it! Secondly (and probably more importantly), my chat definitely needs to have the users name beside their message!comments powered by Disqus