if statement - javascript if function, what am i doing wrong? -


i have written javascript function doesn't seem work. tell me i've gone wrong? should right, after testing bit, generating number bit seems work, think if statement has problem. appreciated

<html>     <head>         <script>             function myfunction()             {                 var x=math.floor((math.random()*3)+1);                 myfunc();             }              function myfunc()             {                 if (x == 1)                 {                     document.write("1")                 }                 else if (x == 2)                 {                     document.write("2")                 }                 else if (x == 3)                 {                     document.write("3")                 }             }         </script>     </head>     <body>         <button onclick="myfunction()">click me</button>     </body> </html> 

pass x function so..

var x=math.floor((math.random()*3)+1); myfunc(x);  function myfunc(x) {     //now can use x } 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -