Hello I am trying to learn the differences from Java and JavaScript so I am trying to take a working simple program in Java and make it work in JavaScript. I keep getting undefined. Here is the JavaScript I am trying:
<script type="text/javascript">
function _(x) {
return document.getElementById(x);
}
function phraseOmatic () {
//print to div id=phrase
_("phrase").innerHTML = phrase;
//make three sets of words to choose from
var wordListOne = ["24/7","multi-Tier","30,000 foot","B-to-B","win-win","frontend","web-based","pervasive","smart","sixsigma","critical-path","dynamic"];
var wordListTwo = ["empowered","sticky","value-added","oriented","centic","distibuted","clustered","branded","outside-the-box","positioned","networked","focused","leveraged","aligned","tageted","shared","cooperative","accelerated"];
var wordListThree = ["process","tippingpoint","solution","architecture","core competency","strategy","mindshare","portal","space","vision","paradigm","mission"];
//find out how many words are in each list
var oneLength = wordListOne.length;
var twoLength = wordListTwo.length;
var threeLength = wordListThree.length;
//generate three random numbers
var rand1 = Math.floor(Math.random() * oneLength);
var rand2 = Math.floor(Math.random() * twoLength);
var rand3 =Math.floor(Math.random() * threeLength);
//now build a phrase
var phrase = wordListOne[rand1] + " " + wordListTwo[rand2] + " " + wordListThree[rand3];
}
window.addEventListener("load", phraseOmatic, false);
</script>