Lets say you have a simple TaffyDB database:
var example = TAFFY([ {fruit:"apple", color:"green", taste:"sweet"}, {fruit:"banana", color:"yellow", taste:"more sweet"}, {fruit:"tomato", color:"red", taste:"like tomato"} ]);
How would you render randomly one fruit after another to HTML: My solution as a javascript beginner:
var fruit = example().count(); var random = Math.floor(Math.random()*count); var fruit = example().select("fruit")[random]; var color = example().select("color")[random]; var taste = example().select("taste")[random]; $(document).ready(function(){ $('#somediv').append("<p>" + fruit + "</p>"); $('#somediv').append("<p>" + color + "</p>"); $('#somediv').append("<p>" + taste + "</p>"); });
I think that this is too complicated.
Would there be another solution to this?