6/10


#1

Hello, i have a problem with this picture. I dont understand, why is the output 59? based on what? i mean u have to multiply celsius with 9/5, but then again, those celsius arent adjusted… So you are multiplying a word with 9/5… Someone please give me an explenation of the result ‘‘59’’celsius


#2

Hi @chipblaster48164,

It somehow worked like this:

//Calling function getFahrenheit, input 15 as argument to replace celsius
getFahrenheit(15);

//function getFahrenheit then return another function, which is multiplyByNineFifths(celsius) + 32;
//The computer knows from the code, the 15 is replacing celsius in function getFahrenheit, is then used to replace the celsius in function multiplyByNineFifths 
//So it becomes:
return multiplyByNineFifths(15) + 32;

//then refer to function multiplyByNineFifths(celsius), the 15 is then again used to replace the celsius inside the function multiplyByNineFifths
//The function multiplyByNineFifths(15) will then return this below:
return 15 * (9/5);

//So in the end from this:
return multiplyByNineFifths(15) + 32;

//It will become this:
return [15 * (9/5)] + 32;

//So calculate that, it will become:
return 59

//So the answer of getFahrenheit(15) will return the number:
59

In simplified version, it happens like this:

//calling function
getFahrenheit (15)

    multiplyByNineFifths (15) + 32
              ^            ^
              |            |
             [(15) * (9/5) ]  + 32

                                 = 59

Hope you can understand that. :slight_smile:


#3

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