Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8407213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:18:08+00:00 2026-06-09T23:18:08+00:00

So this is a simple javascript code which turns money in the digits into

  • 0

So this is a simple javascript code which turns money in the digits into words.
The problem is the browser does not even prompt the window.
I have read the code many times but i am not able to find the error.
Can any one help?

<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>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T23:18:09+00:00Added an answer on June 9, 2026 at 11:18 pm

    Get rid of the else { in the two_digit() function. There is a bracket missing (and the else is not necessary in the code since you always return in the if before it).

    Also get rid of the first return in the code. A return cannot be used outside of a function (if you want a quick but “wrong” way to exit, you can use throw 'End'; but that is really only supposed to be used for errors).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've run into an issue with a simple javascript code, which is pretty much
Check out this code. This is a very simple JavaScript object which is implemented
I have a simple piece of Javascript code and I get this Error :
I have this simple code that speaks for itself. <script language='javascript"> function check() {}
I am new at JavaScript so I think my problem may be simple. This
I have this simple code: <html> <head> <script src=jquery-1.5.1.min.js type=text/javascript></script> <script type=text/javascript> $(function() {
I have the following simple javascript code, which handles the Return Key, I don't
I has a simple JavaScript code which is consuming memory while running infinitely. Memory
I have a very simple Javascript (jQuery) code, which just add a class name
I have a very simple JavaScript operation which is just not working. I'm using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.