Quotes help make search much faster. Example: "Practice Makes Perfect"

Thursday, November 15, 2012

Codecademy: "Rules of the Road"



//sample solution for Hangman Exercise 1

// This array holds the words we are going to choose from.
// Feel free to add new words!
var words = ['cat', 'tree', 'swing', 'around', 'scientist'];

// This function will pick our word
function chooseWord (words) {
    // Write code here
    var index = parseInt(Math.random()*words.length);
    return words[index];
}

//for testing purposes
console.log(chooseWord(words));

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts