What's the point of using function here Practice makes perfect


#1


Why i have to create a function in the code when the code can just run without the function and get the same result?

https://www.codecademy.com/en/courses/javascript-beginner-en-ASGIv/1/1?curriculum_id=506324b3a7dffd00020bf661


//Remember to set your condition outside the loop!
var count=0

var loop = function(){
	while(count < 3){ console.log("I'm looping!");
	count++
		//Your code goes here!
	}
};

loop();


#2

I need same loop 100 times.what will you do now?do you want to write same loop 100 times or just want to call the function 100 times?


#3

The purpose of using a function in this code with an empty parameter is so that you can call loop as a return function. So to end it, it would be loop(count); because loop is a function and count is a variable you can put into the parameters of the function to receive an output.


#4

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