I am just learning the ropes with jQuery and I am trying to create the front end for a simple FizzBuzz game, I have a function as follows...
FizzBuzz.prototype.play = function(number){
if (this.isDivisibleByFifteen(number)) {
return "FizzBuzz";
}
else if (this.isDivisibleByThree(number)) {
return "Fizz";
}
else if (this.isDivisibleByFive(number)) {
return "Buzz";
}
else {
return number;
}
}
I wish to have a an html form which excepts the param (number) and returns the outcome within a span container...
<form id="game">
<input type="text" name = "text" placeholder="Type your number"/>
</form>
<span id="outcome">??</span>```
Here is what I have so far, tear apart as you please...
$(document).ready(function() {
$("#outcome").text(function() {
fizzBuzz.play( $(this).attr("number") );
});
});
Obviously this doesn't take into account any input from the form, but not really to sure how to do that yet. Many thanks.