valen
valen

Reputation: 845

Unexpected identifier error, javascript

I'm getting an unexpected identifier at float farenheitFloat = parseFloat(farenheit)

Can't for the life of me figure out why. Any help?

A little background...validateFarenheit(farenheit) is working.

function convertFarenheit() {
    var farenheit = document.getElementById('farenheit').value;
    if (validateFarenheit(farenheit)) {
        float farenheitFloat = parseFloat(farenheit);
        //float celsius = (farenheitFloat - 32) * (5/9);
        //float celsiusFormatted = parseFloat(Math.round(celsius * 100) / 100).toFixed(2);
        //alert(celsiusFormatted);  
    }
    return;
}

Upvotes: 0

Views: 435

Answers (2)

The111
The111

Reputation: 5867

The problem is in this line:

float farenheitFloat = parseFloat(farenheit);

There is no such thing as a float type (or any strict type declaration) in JavaScript.

Change it to:

var farenheitFloat = parseFloat(farenheit);

Upvotes: 3

Dennis
Dennis

Reputation: 14455

in javascript, you always declare variables via

var myVariable;

You do not specify a type like float,but always say var.

Upvotes: 0

Related Questions