function getNamedRange(n) {
SpreadsheetApp.getActiveSpreadsheet().getRangeByName(n);
}
The first problem, you have not assigned the result of this chained statement to anything. getRangeByName returns an object that references the named range and must be assigned to something, or its result is lost. Second, you have not returned anything in the function.
With these changes you would have:
function getNamedRange(n) {
var result = SpreadsheetApp.getActiveSpreadsheet().getRangeByName(n);
return result
}
(and yes, you can do away with the result variable and just return the full statement. It just looks nicer this way)
That takes care of the getNamedRange function.
Now to deal with the calling part.
var items = getNamedRange("budgetItems"); items.getValues();
Assuming the changes to the function above, you should now have a correctly initializeditems variable1.. It still won't work, as is, however, because the getValues method returns an array for all the cells within the items range. You haven't assigned anything to that.
You should change that line to:
var items = getNamedRange("budgetItems"),
budgetItemsValues = items.getValues();
The array variable 'budgetItemsValues' should now contain all the cell values within the budgetItems named range, formatted as an array of an array.
Once you have that, you can work on the array using the many methods in google app scripting available. But that's beyond the scope of this answer.
1.This is assuming that you pass a valid name range to the getNamedRange function in the first place. If not, then the result will be undefined. This can be checked by using the Array.isArray(object) method which returns true if the object parameter is a valid Array. If you really want to go the full nine yards on error checking, you can check for this in the function, issuing a throw statement, whilst using the try / catch statements when calling into the function. But now I'm really going beyond the scope of this answer ;)...