つまり、これは数字のお金を単語に変換する単純なJavaScriptコードです。問題は、ブラウザがウィンドウにプロンプトを表示しないことです。コードを何度も読みましたが、エラーを見つけることができません。誰か助けてもらえますか?
<script type="text/javascript">
document.writeln("hello World");
var output=new Array("Rs.",null,null,null,null,null,null,null,null,null,null,null,null,null,null);
str=window.prompt("Enter a number:","0");
n1=parseFloat(str);
if(isNaN(n1))
{
docucument.writeln("Enter a Valid number");
return;
}
else
{
paise=(n1%1)*100;
rupee=parseInt(str);
output[14]="paise only";
output[13]=two_digit(paise);
output[12]="and";
x=rupee%100;
output[11]=two_digit(x);
rupee=rupee/100;
//if(rupee<=0) break end;
output[10]="hundred";
x=rupee%10;
output[9]=one_digit(x);
rupee=rupee/10;
//if(rupee<=0) break end;
output[8]="thousand";
x=rupee%100;
output[7]=two_digit(x);
rupee=rupee/100;
//if(rupee<=0) break end;
output[6]="lakhs";
x=rupee%100;
output[5]=two_digit(x);
rupee=rupee/100;
//if(rupee<=0) break end;
output[4]="crore";
x=rupee%100;
output[3]=two_digit(x);
rupee=rupee/100;
//if(rupee<=0) break end;
output[2]="hundred";
x=rupee%10;
output[1]=one_digit(x);
rupee=rupee/10;
//if(rupee<=0) break end;
//end:
document.writeln(output.join(" "));
}
function two_digit(n)
{
if(n>=11 && n<=19)
{
x=eleven(n);
return x;
}
else
{
a=n%10;
y=one_digit(a);
a=n/10;
switch(a)
{
case 1: x="ten";
break;
case 2: x="twenty";
break;
case 3: x="thirty";
break;
case 4: x="forty";
break;
case 5: x="fifty";
break;
case 6: x="sisty";
break;
case 7: x="seventy";
break;
case 8: x="eighty";
break;
case 9: x="ninty";
break;
case 0: x=null;
break;
}
return (x+y);
}
function one_digit(n)
{
switch(n)
{
case 1: x="one";
break;
case 2: x="two";
break;
case 3: x="three";
break;
case 4: x="four";
break;
case 5: x="five";
break;
case 6: x="six";
break;
case 7: x="seven";
break;
case 8: x="eigh";
break;
case 9: x="nine";
break;
case 0: x=null;
break;
}
return (x);
}
function eleven(n)
{
switch(n)
{
case 11: x="eleven";
break;
case 12: x="twelve";
break;
case 13: x="thirteen";
break;
case 14: x="fourteen";
break;
case 15: x="fifteen";
break;
case 16: x="sixteen";
break;
case 17: x="seventeen";
break;
case 18: x="eighteen";
break;
case 19: x="nineteen";
break;
}
return (x);
}
</script>