Code Lab is in development. New lessons and improvements are on the way. Progress can be deleted.
Loading…
Code Lab is in development. New lessons and improvements are on the way. Progress can be deleted.
Loading…
Code Lab is in development. New lessons and improvements are on the way. Progress can be deleted.
JAVASCRIPT FOUNDATIONS / CHAPTER 01 / Learn / LESSON 09
Ninth class. “Income − expense” repeats. Here we learn an ordinary function declaration — a named recipe. Arrow functions come later in Data.
function remaining(income, expense) { return income - expense; }
Parameters are inputs. return sends a result out. Call: remaining(2000, 750) → 1250.
Mini example:
function double(n) { return n * 2; } console.log(double(5));
Common mistake: forgetting return (result is undefined); or calling the function without parentheses.
return sends a value back to the caller. A constant answer will fail.
BUDGET STANDBY
›