Functions calling on other functions

I’m doing a basic program for my beginners coding class. This assignment is on functions. I need to use a function to call on another and the second returns a value to the first for output to the user. This particular program is to determine the Wind Chill in Fahrenheit using two user inputs. I keep getting an error in debugging telling me the variable I’ve assigned for the return is not assigned. But a couple lines above it is assigned. I’ve banged my head a bunch, re-read the class material, and compared my code to the code examples given in class. Please let me know what I am missing. Thank you.

<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<title>Find Wind Chill In Fahrenheit</title>
<script language="javascript" type="text/javascript">

function doInputOutput () {
//Can I remove the var from the input?
var temp = parseFloat (document.getElementById('temp').value);
var windSpeed = parseFloat (document.getElementById('windSpeed').value);
//windChill();
var itsCold = windChill(temp,windSpeed)

var div = document.getElementById ('output');
	div.innerHTML = itsCold;
}

function windChill (t,v) {

var itFeelsLike = 35.74 + 0.6215 * t -35.75* a + .4275 * t * a;
var a = Math.pow(v,.16);


//I got the formula from www.onlineconversion.com/windchill.htm.  
//I verified the formula from a few separate sources as well

//var itFeelsLike =___________
return itFeelslike;

}


</script>
</head>
<body>

<input type="text" id="temp"> Temperature </input>
<input type="text" id="windSpeed"> Wind Speed </input>
</br>
</br>
<button type="button" onClick="doInputOutput();">Wind Chill</button>
<!--<button type="button" onclick="fifteen();">Click</button>-->
<div id="output"></div>
</body>
</html>

The variables are case-sensitive, so make sure that the upper and lower case letters in your variable names are all the same. The itFeelsLike variable is spelled differently on the return, for example.

Then in that same function, you have a line that uses the a variable when that variable hasn’t been defined yet.`

Thank you. I could have sworn I looked at that. I will chalk this one up to staring at the problem for too long.

I corrected the capitalization of the return line, and moved the “var a” line above the “var itFeelsLike” line and the program works correclty now.

I’ve noticed your comments on a number of my posts. Thank you for taking the time to help me through my program issues.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.