Basic Javascript (79/111) | Return Early Pattern for Functions | freeCodeCamp

preview_player
Показать описание
Basic Javascript (79/111) | Return Early Pattern for Functions | freeCodeCamp

"When a return statement is reached, the execution of the current function stops and control returns to the calling location.

Example

function myFun() {
return ""World"";
}
myFun();
The above outputs ""Hello"" to the console, returns ""World"", but ""byebye"" is never output, because the function exits at the return statement.

Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined.

Hint
Remember that undefined is a keyword, not a string."
Рекомендации по теме
Комментарии
Автор

Thank you sir I was stuck on this one originally it was the equal signs in the if (a < 0 || b < 0) {
return undefined;
} code

zken