A custom function lets a cell call JavaScript that you define in Extensions > Apps Script. A function named LINE_TOTAL can appear in a cell as =LINE_TOTAL(B2,C2). Its parameters receive the values from those cells, and its return statement sends the answer back to the sheet.
Use return for a custom function. Writing a number to the execution log doesn't make that number the cell's result. A range argument arrives as an array of rows, even when the range has only one column. Return an array of rows to spill several results into neighboring cells.
The practice editor runs a supported subset of JavaScript and spreadsheet services. It does not connect to your real Google account. Custom functions here calculate from their arguments; scripts that change cells directly are covered next. Keep zero values distinct from blanks, and guard divisions when the denominator can be zero.