Function with return; etc

function stepChk(f) {
	var all_ok = true;
	if (f.username.value.length < 2) { all_ok = false; }
	var msg = 'Your username must be 2 to 12 letters long !';
	if (!all_ok) { alert(msg); }
	return all_ok;
}

Can somebody explain what this function do exactly?

What if there is no return? Or just return;

Thanks!

This is not that complicated of a function. What do you think it does?

If a function doesn’t explicitly return a value then it automatically returns undefined.

The function is a parametized function that is expecting an object which then check if the length value of the username property of the object is lesser than 2 then reset all_ok variable to false. Then set the variable message and recheck for the not value of all_ok to alert the message variable. In a simple sentence this function was supposed to make sure the length of username is greater than 2. It return all_ok because i believe this function will be assign to a variable e.g

var all_ok = stepChk(obj);

which means the progammer has the need for the variable somewhere in the program. It is not compulsory you make a function return something.