Return early from function
A
return
statement stops the function and skips any code that comes after it — but only if it runs. With an if
statement, we can choose to exit the function early when a condition isn’t met. In the code below, the function returns early if num
is smaller than 5. Update the code so that result
becomes 25
.Premium
JavaScript
Console