MCD - Level 1 Exam QuestionsBrowse all questions from this exam

MCD - Level 1 Exam - Question 62


A function named newProdCode needs to be defined that accepts two input parameters, an integer value for ItemID and a string value for productCategory, and returns a new product code.

What is the correct DataWeave code to define the newProdCode function?

A.

B.

C.

D.

Show Answer
Correct Answer:

The correct answer is A. In DataWeave, to define a function, you use the `fun` keyword followed by the function name and equals sign `=`. The arrow `->` is used for lambda functions and not for defining named functions. Therefore, the correct syntax to define the `newProdCode` function that accepts an integer value for ItemID and a string value for productCategory is correctly illustrated in option A. The other options incorrectly use `->` which cannot be used in this context.

Discussion

15 comments
Sign in to comment
chengl
May 10, 2021

A is correct. https://docs.mulesoft.com/mule-runtime/4.3/dataweave-functions

Zumo
May 28, 2021

Yes, you are correct. C gives a dataweave error. -> cannot be used. Most people will think because if '?' A is wrong. But A is the Correct Answer.

Swoody77
Sep 21, 2021

The answer is A, as others have put, the -> symbols cannot be used in a function like this, only =.

xasihih752
Feb 14, 2024

You're right, as a general rule, lambda functions cannot be named

thamizhanda
Dec 4, 2021

The answer is A, as '->' symbol is used in option C which is not a valid syntax in a function and it should be '='

senthil_Kumar_Murugan
Dec 8, 2021

A is the correct Answer we neeed to use "=" in function

maeda
Jan 18, 2022

fun myFunction(param1, param2, ...) = <code to execute> its = cannot ->

mohammad_jani
Feb 9, 2022

A is the correct answer

frediepulgoso
Mar 7, 2022

A is correct

Carolinek
May 29, 2022

A is correct

lelebc10baar
Dec 9, 2022

A CORRECT ANS - syntax is right here

MULEMADDY
Jan 2, 2023

A is correct

Nazarii
Apr 12, 2023

A Correct

Pavankumar142
Dec 13, 2023

A is correct

AntarJalil
Jan 5, 2024

Yep it is A. The only issue I saw on option A is that ""productCategory" is defined as "string" instead of "String" ( 's' instead of Capital S). However, if I also define a custom type (type string = String ) , it works fine . I just tried . so it is A the right answer .

ExamDev
Jan 22, 2024

A is correct.

ExamDev
Jan 25, 2024

A is correct