Salesforce Certified MuleSoft Developer I — Question 13

A function named toUpper needs to be defined that accepts a string named userName and returns the string in uppercase.
What is the correct DataWeave code to define the toUpper function?

Answer options

Correct answer: B

Explanation

The correct answer is B because in DataWeave, functions are defined using the 'fun' keyword followed by the function name and parameters. Answers A and C incorrectly use 'var' instead of 'fun', and D incorrectly uses '->', which is not the correct syntax for defining a function that returns a value.