Missing lesson in the Javascript coursework?

About the Javascript lessons…I don’t seem to recall anything in any of the Javascript lessons leading up to the “Convert Celsius to Fahrenheit” exercise stating that using the word “celsius” in the formula was going to pass the number through from the input.

function convertToF(celsius) {
  var fahrenheit;
  // Only change code below this line

  fahrenheit = celsius * (9 / 5) + 32;

  // Only change code above this line
  return fahrenheit;

// Change the inputs below to test your code

I was just kinda guessing and tossing the word in as what I thought was pseudocode to be a placeholder while I sought help. It just happened to be the right thing to do, but I didn’t know that going in. Am I wrong about this? Was this covered by the coursework and I just forgot about it?

If not, that strikes me as a bit of a glaring oversight for someone who might be unfamiliar with this particular behavior.

If you were doing the challenges in order, then there should have been a few challenges before this showing you basic arithmetic operations. The convertToF challenge is intended to bring those challenges together and illustrate how you can build more complex operations.

The arithmetic operations aren’t the issue. It’s that nowhere that I could find in the previous lessons was there any indicator that when the function ran the word “celsius” would be used as a variable that passed through the input whenever “convertToF()” was called. I get it now, but at the time I first saw this I was honestly at a loss for how I was supposed to tell the function to get the number from between the parenthesis in the bottom code and pump it through in the place of the word “celsius” in the function call. I can’t imagine I’m the only person to be confused by that.

You are given a variable celsius representing a temperature in Celsius.

Is in the challenge description.

PrincessColumbia I think you could be right about this challenge. It seems out of place. Maybe it is meant to come a few lessons later? or a curve ball to force you to figure it out?

I found this lesson that comes way after that seems to explain your question about functions.

the note explicitly states that you don’t need to worry about it, as it will be covered in later materials

Don’t worry too much about the function and return statements as they will be covered in future challenges. For now, only use operators that you have already learned.

Basically the challenge says, I’m going to give you a number called Celsius, you do what you need to do to turn it into Fahrenheit, and let the existing codes handle the rest.

You don’t need to know function parameters/arguments to complete the exercise, as the function was just a tool in this case for simpler testing condition for multiple numbers so you can’t just hard code in a solution.

I think I’m not communicating my point very well.

The problem isn’t that the parameter is being defined and the code will handle it and yadda, the problem is there’s a big-ol nothing to tell me that the parameter will automatically be assigned from the inputs.

OK, let’s try this way:

function foo(bar) {

var variable1;

variable1 = bar + "clear?";

return variable1;

So if I feed the above function with the following input:

foo("Am I ")

I know now that the string "Am I " will be automatically subbed out for the word “bar” in the function, but prior to just randomly experimenting I was turning mental summersaults trying to figure out how to get the variable “bar” to grab the string "Am I " from the input. I was given no knowledge or preparation for the defined input being passed through with no input or code on my part.

I’m probably still making no sense, but hopefully this communicates something of the concept I’m trying to explain.

I think the point is you don’t need to know.

The prompt tells you the Celcius is a variable that represents temperature in Celcius, which is all you need to know. As long as you know how variables work, it was enough to answer the question.

To me it’s like there’s a question: A bottle of milk cost $5, how much is 5 bottles of milk?

You’re asking why is the milk $5.

If we take the function part out of it, would you have been answer the question like this?

An unknown temperature in Celsius will be assigned to the variable C, using the operators you've learned, convert Celsius into Fahrenheit and assign the value to variable F

1 Like