FoMS Experts

News / Exam Questions

QUESTION, ANSWER, EXPLANATION

Exam Question MS-21-040 for MuleSoft Certified Developer (MCD) - Level 1

Exam Question MS-21-040 for MuleSoft Certified Developer (MCD) - Level 1
Share
FacebookGoogle plusLinkedInStumbleuponTwitter
FoMS12.4.2021

This question has been asked by one of our members and a similar question could most likely be on the exam. All answers have been verified by MuleSoft certified FoMS experts.

Question

A function named newProdCode needs to be defined to accept two input parameters, an integer value for itemID and a string value for productCategory, and to return a new product code. What is the correct DataWeave code to define the newProdCode function?

Answer

A) fun newProdCode(itemID: Number, productCategory: String) —> "PC-" ++ productCategory ++ (itemID as String)

B) fun newProdCode(itemID: Number, productCategory: String) = "PC-" ++ productCategory ++ (itemID as String)

C) function newProdCode(itemID: Number, productCategory: String) = "PC-" ++ productCategory ++ (itemID as String)

D) var newProdCode(itemID: Number, productCategory: String) —> "PC-" ++ productCategory ++ (itemID as String)

The correct answer to this question is B.

Explanation

To define a function in DataWeave the following syntax has to be used: fun myFunction(param1, param2, ...) = "code to execute"

That leads us to the correct answer B.

Register now