
Explanation:

Box 1: getContext().getRequest();
Box 2: if(isNaN(i)["tip"] ..
In JavaScript, there are two ways to check if a variable is a number :
isNaN() - Stands for "is Not a Number", if variable is not a number, it return true, else return false.
typeof - If variable is a number, it will returns a string named "number".
Box 3:r.setBody(i);
// update the item that will be created
References:
https://docs.microsoft.com/bs-latn-ba/azure/cosmos-db/how-to-write-stored-procedures-triggers-udfs
https://mkyong.com/javascript/check-if-variable-is-a-number-in-javascript/