Week 2 - 122v4.htm

<SCRIPT>

var myColor, mySentence;

// making sure that one of the appropriate colors is entered
while (myColor != "red" && myColor != "green" && myColor != "blue") {
     myColor = null;    

     // if the user "cancels out" bring back the prompt until he or she enters something
     while (!myColor) myColor =
prompt("Enter Color \(Red/Green/Blue\):", "blue")

     // in order to make a comparison in the above while() check
     myColor = myColor.
toLowerCase();
}

mySentence = prompt("Enter a sentence", "Let's see what happens!");

// if the user "cancels out" the sentence make "Let's see what happens!" the default sentence
if (!mySentence) mySentence = "Let's see what happens!";

document.write(mySentence.fontcolor(myColor).bold());

</SCRIPT>