Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

158
Views
NUMBERS TO WORDS using html and javascript

NUMBER TO WORDS convert number to word in javaScript displayed take output from user using HTML page easy and simple using for and switch statement

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <br><br>
    <h1>NUMBER TO WORDS</h1>
    <input type="5ber" id="nm1" placeholder="number"><br><br>
    <input type="button" value="To Words" id="optin" onclick="pldstrng()">
    <p id="value" style="color: blueviolet;"></p>

    <script>
        function pldstrng() {
            var k = document.getElementById("nm1").value
            var a = String(k)
            for (let i = 0; i < a.length; i++) {
                switch (a[i]) {
                    case "1":
                        document.getElementById("value").innerHTML+="one"+" " 
                        break
                    case "2":
                        document.getElementById("value").innerHTML+="two"+" "
                        break
                    case "3":
                        document.getElementById("value").innerHTML+="three"+" "
                        break
                    case "4":
                        document.getElementById("value").innerHTML+="four"+" "
                        break
                    case "5":
                        document.getElementById("value").innerHTML+="five"+" "
                        break
                    case "6":
                        document.getElementById("value").innerHTML+="six"+" "
                        break
                    case "7":
                        document.getElementById("value").innerHTML+="siven"+" "
                        break
                    case "8":
                        document.getElementById("value").innerHTML+="eight"+" "
                        break
                    case "9":
                        document.getElementById("value").innerHTML+="nine"+" "
                        break
                    case "0":
                        document.getElementById("value").innerHTML+="zero"+" "
                        break
                    default :
                        document.getElementById("value").innerHTML="enter a number / digit"+" "    
                }
            }
        }
    </script>
</body>

</html>

about 4 years ago · Juan Pablo Isaza Report

0

this might help you , i dont think there is a more straight forward way than this.

var num = "zero one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen".split(" ");
var tens = "twenty thirty forty fifty sixty seventy eighty ninety".split(" ");

function number2words(n){
    if (n < 20) return num[n];
    var digit = n%10;
    if (n < 100) return tens[~~(n/10)-2] + (digit? "-" + num[digit]: "");
    if (n < 1000) return num[~~(n/100)] +" hundred" + (n%100 == 0? "": " and " + number2words(n%100));
    return number2words(~~(n/1000)) + " thousand" + (n%1000 != 0? " " + number2words(n%1000): "");
}

https://www.codegrepper.com/code-examples/javascript/convert+number+to+words+in+javascript

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!