0

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;
}
2
  • 8
    Should be var not float Commented Apr 12, 2013 at 8:08
  • 1
    as esalija said it should be var farenHeitFloat = parseFloat(farenHeit) Commented Apr 12, 2013 at 8:09

2 Answers 2

3

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);

Sign up to request clarification or add additional context in comments.

Comments

0

in javascript, you always declare variables via

var myVariable;

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.