XpertWorlock Posted January 6, 2009 Share Posted January 6, 2009 New to Javascript, so this could be a stupid error on my part. How come this works? function giveCard() { return '5'; }; dealerCard[0] = giveCard(); document.getElementById("dealerCardPosition0").innerHTML = '<div id="dealerCard0" class="card" >' + dealerCard[0] + '</div>'; and this doesn't function giveCard() { return (Math.random * 10); }; dealerCard[0] = giveCard(); document.getElementById("dealerCardPosition0").innerHTML = '<div id="dealerCard0" class="card" >' + dealerCard[0] + '</div>'; Quote Link to comment Share on other sites More sharing options...
tomfmason Posted January 6, 2009 Share Posted January 6, 2009 NaN means "Not a Number". Try using parseFloat() to convert the string to an integer. Quote Link to comment Share on other sites More sharing options...
XpertWorlock Posted January 6, 2009 Author Share Posted January 6, 2009 No, code seems to work better when you use function correctly Math.random Math.random() my bad Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.