PdfPrep.com

How should you complete the trigger?

HOTSPOT

You have a web service that is used to pay for food deliveries. The web service uses Azure Cosmos DB as the data store.

You plan to add a new feature that allows users to set a tip amount. The new feature requires that a property named tip on the document in Cosmos DB must be present and contain a numeric value.

There are many existing websites and mobile apps that use the web service that will not be updated to set the tip property for some time.

How should you complete the trigger? NOTE: Each correct selection is worth one point.

Answer:

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() C Stands for “is Not a Number”, if variable is not a number, it return true, else return false.

typeof C 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/

Exit mobile version