lundi 25 février 2019

javascript multiplication table order

I have the followign school project:

  • You enter a number into a prompt
  • Highlights every occurance of numbers in interval [1; 100] that are the multiplicator of the inputted number.

Issue is, whenever I input a number dividable by /5 it ruins the table formatting with the extra <br/>

<html>
<body>
    <script>

        var y = prompt("enter a number between 1 -100 ")
            if( y<=100 && y>=1 ){
                for (i = 1 ; i<=100 ; i++){
                var idk = i + " "
                    if (i%y!=0){
                    document.write(idk)
                    }
                    if(i%10==0 ){
                        document.write("</br>" )
                        console.log(i)
                    }

                     if(i%y==0){

                        document.write(idk.fontcolor("red"))
                    }
                }





            }
            else {
            document.write("your number isnt good")
            }

    </script>
</body>

this is my code can someone help me fix it

Aucun commentaire:

Enregistrer un commentaire