Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Enter Decimal Number


Select Base

Base 2 Base 16



Output

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Implementing Ai And Machine Learning For Business Optimization

Authors: Robert K Wiley

1st Edition

B0CPQJW72N, 979-8870675855

More Books

Students also viewed these Databases questions