Last active
May 3, 2017 11:19
-
-
Save purplecones/750a28f74197cdd853c3eae7b146bbb1 to your computer and use it in GitHub Desktop.
Exported from Popcode. Click to import: https://popcode.org/?gist=750a28f74197cdd853c3eae7b146bbb1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>Class Randomizer</title> | |
| </head> | |
| <body> | |
| <h1>Randomly Choose a Student</h1> | |
| <button id="studentButton">Click me to pick one random student</button> | |
| <div id="studentDisplay"></div> | |
| <h1>Randomly Choose a Teacher</h1> | |
| <button id="teacherButton">Click me to pick four random teachers</button> | |
| <div id="teacherDisplay"></div> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {"enabledLibraries":["jquery"]} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var teachers = [ | |
| "Brian", | |
| "Mirza", | |
| "Carol", | |
| "Eliza", | |
| "Karl", | |
| "Jonathan", | |
| "Christian", | |
| "Melissa" | |
| ]; | |
| var students = [ | |
| "Haoxi", "Maria Lucia", "Bhutika", | |
| "Sami", "Jonathan", "Miguel", | |
| "Hassany", "Yuna", "Margaux", | |
| "Diego", "Laura", "Zhindel", | |
| "Isaac", "Milena", "Luka", | |
| "Linhong", "Edwin","Adrian", "Fior", | |
| "Mohamed", "Yancy", "Mahadi", | |
| "Sallam", "Oumar", "Griselda", | |
| "Maria Gomez", "Marco" | |
| ]; | |
| $('#studentButton').click(function () { | |
| // get a random number | |
| // how do we fix this to pick from all students from the student array? | |
| var randomNumber = Math.floor(Math.random() * 2); | |
| // get a random student | |
| var randomStudent = students[randomNumber]; | |
| // display student name | |
| $('#studentDisplay').append('<p>' + randomStudent + '</p>'); | |
| }); | |
| // USING LOOPS pick four random teachers from the teachers array and display them on the screen | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment