Question
Having issue with following code on JSFIDDLE. Seems right but when I try to run code it states SyntaxError expected expression, got }. Not sure
Having issue with following code on JSFIDDLE. Seems right but when I try to run code it states SyntaxError expected expression, got }. Not sure what is incorrect here.
HTML
JavaScript Converter
JAVASCRIPT
function convert(){ //alert(1); var decimalNumber = document.form1.decimalNumber.value; var element = document.form1.base; var base = 0; //Ger option for (var i=0; i < element.length; i++) { if (element[i].checked) { base = element[i].value; break; } }
var binary = ""; //loop until 0 while(decimalNumber > 0){ //Mod by base var temp = decimalNumber % base; //alert(temp); binary = temp + binary ; //Division by base decimalNumber = Math.floor(decimalNumber / base); //alert(dec); } alert(binary); document.form1.output.value = binary; return binary; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started