# willknott/willknott-CoderDojo-HTML5-dice01

`Signed-off-by: Will Knott <Will@WillKnott.ie>`
1 parent 4a8f508 commit 05d9e873576759a62d90aaa209ea7c033bd605ef committed May 14, 2012
Showing with 71 additions and 0 deletions.
1. +11 −0 05simplespinningworddice.html
2. +24 −0 05spinningworddice.js
3. +25 −0 06decisionmaker.js
4. +11 −0 06simpledecisionmaker.html
 @@ -0,0 +1,11 @@ + + + + + 05 spinning word dice + + + + + +
 @@ -0,0 +1,24 @@ +var arrt = ["one", "two", "three", "four", "five", "six"]; +var arr = 6; + +//roll a dice with arr sides +var roll = function (listofwords) { + //why are we no longer adding the one? + dice = Math.floor(Math.random()*listofwords.length); + //return the word at position ... + return(listofwords[dice]); + }; + +//Instead of calling almost the same line 6 times, loop it and recreate it +for (i=0; iHello World ' + roll(arrt) + '!'); + } + else if (i == 2){ + document.write('
Coder Dojo
'); + } + else { + document.write('
'); + } + +};
 @@ -0,0 +1,25 @@ +arrt = ["It is certain", "It is decidedly so", "Without a doubt", "Yes, definitely", "You may rely on it", "As I see it, yes", "Most likely", "Outlook good", "Signs point to yes", "Yes", "Reply hazy, try again", "Ask again later", "Better not tell you now", "Cannot predict now", "Concentrate and ask again", "Don't count on it", "My reply is no", "My sources say no", "Outlook not so good", "Very doubtful"]; + +var arr = 6; + +//roll a dice with arr sides +var roll = function (listofwords) { + //why are we no longer adding the one? + dice = Math.floor(Math.random()*listofwords.length); + //return the word at position ... + return(listofwords[dice]); + }; + +//Instead of calling almost the same line 6 times, loop it and recreate it +for (i=0; i' + roll(arrt) + '!'); + } + else if (i == 2){ + document.write('
Coder Dojo
'); + } + else { + document.write('
'); + } + +};
 @@ -0,0 +1,11 @@ + + + + + 06 Decision maker + + + + + +