Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function chooseActivity() {
- m = 0;
- n = 0;
- commaAmount = 0;
- options = [];
- input = document.getElementById("txtInput").value;
- for (var i = 0; i < input.length; i++) {
- if (input.charAt(i) == ",") {
- commaAmount++;
- }
- }
- for (var j = 0; j < commaAmount + 1; j++) {
- options[j] = "";
- }
- for (n = 0; n < input.length; n++) {
- if ((input.charAt(n) == ",") && (input.charAt(n + 1) == " ")) {
- n++;
- m++;
- }
- else {
- options[m] += input.charAt(n);
- }
- }
- output = options[Math.floor(Math.random() * options.length)];
- document.getElementById("divOutput").innerHTML = output;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement