I don't get this?


#1

What I don't get is shouldn't there be a variable beforehand that defines the number 8 or another number as in var numHours =8;
I mean it is correct for the lesson but how? How do we know how many hours numHours is?

// Write your function below. 
// Don't forget to call your function!
function sleepCheck(numHours){
    if (numHours >= 8){
        return "You're getting plenty of sleep! Maybe even too much!";
        }else{
        return "Get some more shut eye!";   
            }
    }

#2

function parameters (numHours) are placeholders until you call the function, then the value you supply as argument gets copied into numHours


#3

Yeah I think since I am more used to PHP is where i am confusing things


#4

php has the same concept of functions and parameters:

      <?php
         function addFunction($num1, $num2) {
            $sum = $num1 + $num2;
            echo "Sum of the two numbers is : $sum";
         }
         
         addFunction(10, 20);
      ?>

i don't see any difference in concept?


#5

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