Permalink
Browse files

Files added as class progresses

Signed-off-by: Will Knott <Will@WillKnott.ie>
  • Loading branch information...
1 parent 4a8f508 commit 05d9e873576759a62d90aaa209ea7c033bd605ef @willknott 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 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8">
+ <title>05 spinning word dice</title>
+ </head>
+ <body>
+ <script src="05spinningworddice.js"></script>
+ </body>
+
+</html>
View
@@ -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; i<arr; i++){
+ if (i == arr-1){
+ document.write('<div id="divnum'+ i +'">Hello World ' + roll(arrt) + '!</div>');
+ }
+ else if (i == 2){
+ document.write('<div id="divnum'+ i +'">Coder Dojo</div>');
+ }
+ else {
+ document.write('<div id="divnum'+ i +'"> </div>');
+ }
+
+};
View
@@ -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<arr; i++){
+ if (i == arr-1){
+ document.write('<div id="divnum'+ i +'">' + roll(arrt) + '!</div>');
+ }
+ else if (i == 2){
+ document.write('<div id="divnum'+ i +'">Coder Dojo</div>');
+ }
+ else {
+ document.write('<div id="divnum'+ i +'"> </div>');
+ }
+
+};
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8">
+ <title>06 Decision maker</title>
+ </head>
+ <body>
+ <script src="06decisionmaker.js"></script>
+ </body>
+
+</html>

0 comments on commit 05d9e87

Please sign in to comment.