- Home /
Question by
question boie · Mar 17, 2011 at 02:47 PM ·
stringvoidget
returning a variable in javascript
function GetInitialTemp(Temp : String) { // add the code to get the actual variable var tempvar = reference.GetTemperature();
Temp = tempvar.ToString();
return Temp;
}
for some reason it doesn't like return temp, can you not do this in javascript?
Comment
Answer by Meltdown · Mar 17, 2011 at 02:53 PM
You don't need to pass in Temp as an argument. As it seems you are simply assigning to it anyway.
To return the temperature, simply change your method to...
function GetInitialTemp() {
var tempvar = reference.GetTemperature();
return tempvar.ToString();
}
or more concise...
function GetInitialTemp() {
return reference.GetTemperature().ToString();
}