hi i am trying to avoide using the toString function and instead using arrays for denary to binary, but my program doesn't work. i know it has to do with syntax errors but could someone show me them? thank you!
<!DOCTYPE html> <html> <body> <title> Denary to Binary </title> <header class="Header"> <div class="border"> <div class="space"> <h1> Denary to Binary Converter </h1> </div> </div> </header> <div class ="divider"> <p class ="body"> please insert a denary number below 255 (8bit) </p> </div> <form id = "myform"> <input id="denary" type="text" placeholder="input number here"> <button type="submit" class="btn">enter</button> </form> <form id ="myText"> <input id="binary" class="btn" type="text" placeholder="answer"> </form> <style> html, body { font-family: 'Arial Black", Gadget, sans-serif'; h1 { font-size: 50px; border-bottom: 2px solid green; padding-left: 20px } .btn { paddding: 13px 15px; border: none; background-color: #D3D3D3; } </style> <script> function DeToBi() { var bi = [] var De = document.getElementById("denary").value; if (De > 255) { document.getElementById("myText").value = "your number is bigger than 255"; } else if (Dee - 128 >= 0) { De = De - 128; bi.push("1"); } else { De = De - 0; bi.push("0") } if (De - 64 >= 0) { De = De - 64 ; bi.push("1"); } else { De = De - 60; bi.push("0"); } if (De - 32 >= 0) { De = De - 32; bi.push("1"); } else { De = De - 0; bi.push("0"); } if (De - 16 >= 0) { De = De - 16; bi.push("1"); } else { De = De - 0; bi.push("0"); } if (De - 8 >= 0) { De = De - 8; bi.push("1"); } else { De = De - 0; bi.push("0"); } if (De - 4 >= 0) { De = De - 4; bi.push("1"); } else { De = De - 0; bi.push("0"); } if (De - 2 >= 0) { De = De - 2; bi.push("1"); } else { De = De - 0; bi.push("0"); } if (De - 1 >=0) { De = De - 1; bi.push("1"); } else { De = De - 0; bi.push("0"); } document.getElementById("myText").innerHTML = bi; </script> </body> </html>
<!DOCTYPE html> <html> <body> <title> Denary to Binary </title> <header class="Header"> <div class="border"> <div class="space"> <h1> Denary to Binary Converter </h1> </div> </div> </header> <div class ="divider"> <p class ="body"> please insert a denary number below 255 (8bit) </p> </div> <form id = "myform"> <input id="denary" type="text" placeholder="input number here"> <button type="submit" class="btn">enter</button> </form> <form id ="myText"> <input id="binary" class="btn" type="text" placeholder="answer"> </form> <style> html, body { font-family: 'Arial Black", Gadget, sans-serif'; h1 { font-size: 50px; border-bottom: 2px solid green; padding-left: 20px } .btn { paddding: 13px 15px; border: none; background-color: #D3D3D3; } </style> <script> function DeToBi() { var bi = [] var De = document.getElementById("denary").value; if (De > 255) { document.getElementById("myText").value = "your number is bigger than 255"; } else if (Dee - 128 >= 0) { De = De - 128; bi.push("1"); } else { De = De - 0; bi.push("0") } if (De - 64 >= 0) { De = De - 64 ; bi.push("1"); } else { De = De - 60; bi.push("0"); } if (De - 32 >= 0) { De = De - 32; bi.push("1"); } else { De = De - 0; bi.push("0"); } if (De - 16 >= 0) { De = De - 16; bi.push("1"); } else { De = De - 0; bi.push("0"); } if (De - 8 >= 0) { De = De - 8; bi.push("1"); } else { De = De - 0; bi.push("0"); } if (De - 4 >= 0) { De = De - 4; bi.push("1"); } else { De = De - 0; bi.push("0"); } if (De - 2 >= 0) { De = De - 2; bi.push("1"); } else { De = De - 0; bi.push("0"); } if (De - 1 >=0) { De = De - 1; bi.push("1"); } else { De = De - 0; bi.push("0"); } document.getElementById("myText").innerHTML = bi; </script> </body> </html>
Comment