Question 5/11


#1

hello, every time I run this code, my browser keeps on crashing. Can someoneplease run this and see if you have the same problem:

var count = 3;

var loop = function(count){
while(count < 3){
console.log("I'm looping!");
}
};

loop();

Thanks in advance.


#2

@mc_yemi_ako,

#### Reference::
google search
== the Book ==
javascript while site:developer.mozilla.org
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/while

===============================================

the FUNCTION talk

var myFunc = function( param1, param2) {
       //Begin of  anonymous FUNCTION-BODY
       //VARIABLE -myFunc- has an -anonymous function- assigned
       //this -anonymous function- has 2 PARAMETERS param1 and param2
       //param1 and param2 PARAMETERS are used 
       //as -local- VARIABLES throughout the FUNCTION-BODY

      console.log( param1 + " and " + param2 ) ;

      //End of anonymous FUNCTION-BODY
};

If you want to call/execute the anonymous function
you will have to add a pair of parentheses to the variable myFunc
like
myFunc();
As the anonymous function was defined
as having 2 parameters
you have to provide 2 arguments
in our case 2 string VALUES "Alena" and "Lauren"
like
myFunc("Alena","Lauren");

some quotes from the outer-world:

**argument is the value/variable/reference being passed in,
parameter is the receiving variable used within the function/block**

OR

**"parameters" are called "formal parameters",
while "arguments" are called "actual parameters".**


#3

@mc_yemi_ako,

With

var count = 3;
// count is now a so-called  GLOBAL-VARIABLE

var loop = function(count){
        //Begin of FUNCTION-BODY
	while(count < 3){
	console.log("I'm looping!");
	}
        //End of FUNCTION-BODY
};

you have created a loop =function= which takes 1 parameter count.

This count parameter will be a =local= Variable
within the FUNCTION-BODY of the loop =function=

If you call the loop =function= without an argument
like

 loop();

the =local= variable count in your loop-FUNCTION-BODY will render to undefined
and a while-loop condition of count < 3 will render to false
and there-for your while-loop execution-body will NOT run.


#4

Hello, I have the same problem here.
I was wondering if there there is a possibility of you writing the exact code that we need to write? I would appreciate that, because later I will analyze it myself and learn where I did wrong. Because by reading what you have posted above I'm afraid I don't understand anything and I am getting even more lost.
Thanks in advance! :smile:


#5

loool same. That is exactly what i was thinking haha. But he was being helpful though