Skip to main content
2 of 6
added 1056 characters in body

How am I doing, on learning JavaScript?

How am I doing, on learning JavaScript?

This is just playing around and practicing javascript. I am learning JavaScript from codecademy and I practice coding everyday so I can learn much as possible. I have alot of if statements, prompt boxs, some alert boxs. I just got finished learning about functions, returns. I just don't know how to use the return in a browser for like document.write or even a alert box.

I was told to come here, since it's not allowed on Stackoverflow.

     function prompter(){
    var toc = prompt("What do you prefer? Tea or Coffee");
    if ((toc == "tea") || (toc == "Tea")){
    }
    else if ((toc == "coffee") || (toc == "Coffee")){
    }
    var foc = prompt("What do you prefer? Facebook or MySpace");
    if ((foc == "facebook") || (foc == "Facebook")){
    }
    else if ((foc == "myspace") || (foc == "Myspace")){
    }
    document.write("<center><h2>So you like " + toc + " and " + foc + " that is awesome.</h2></center>");
    }
    function pickAColour(){
    var fun = prompt("What is your favorite colour? , mine is red.");
    document.write("<center><h2>You like the colour " + fun + " that is a nice colour</h2></center>");
    }
    function pickANumber(){
    alert("Lets do some math, do you like Math?");
    var pan = prompt("Please pick a number");
    var nap = prompt ("Please pick another number");
    var symbol = prompt("Please pick one of the following symbols +  -  *  /");
    pan = parseInt(pan);//The parseInt() function parses a string and returns an integer.
    nap = parseInt(nap);//The parseInt() function parses a string and returns an integer.
    if (symbol == "+"){
    alert("You picked the Add symbol");
    alert("Lets add both these numbers together. " + pan +" " +symbol+ " " + nap);
    document.write("<center>Your number is " + (pan + nap)+"</center>");
    }
    if (symbol == "-"){
    alert("You picked the Minus symbol");
    alert("Lets Minus both of these numbers. " + pan +" " +symbol+ " " + nap);
    document.write("<center>Your number is " + (pan - nap)+"</center>");
    }
    if (symbol == "*"){
    alert("You picked the Multiply symbol");
    alert("Lets Multiply both these numbers. " + pan +" " +symbol+ " " + nap);
    document.write("<center>Your number is " + (pan * nap)+"</center>");
    }
    if (symbol == "/"){
    alert("You picked the Divide symbol");
    alert("Lets Divide both these numbers. " + pan +" " +symbol+ " " + nap);
    document.write("<center>Your number is " + (pan / nap) +"</center>");
    }
    }
    function run(){
    var name = prompt("What is your name?");
    document.write("<h1><center>Welcome to this special JavaScript page " + name +"</center></h1>");
    prompter();
    pickAColour();
    pickANumber();
    document.write("<center>Thank You for visting this page</center>");
    }

run();

Edit: Sorry, some how the whole script wasn't there. Still New here.