Why isn't the Javascript Transformer switch working

Hi, I was hoping to output the textArea1 label with switch. However whenever i construct the switch it wouldn't return the value as expected. I also tried returning some random number but it won't work as usual whenever I construct a switch command. It will only work normally once i get rid of the switch. May I know what is the reason behind this and how should I solve this? Thanks!

Add on:

I have add in the missing "break" in the third case of switch but it is still not working. The preview say that * message:"Unexpected token 'switch'".

1 Like

Cannot assign from a switch statement like this

let openingBlurb = 
    switch( ) {

Just the switch by itself should work

switch( ) {
    case 'Too late':
        return "I'm so sorry about your order being late..."

@edison6986 did you find a solution ? i'm trying to do a switch case for color , but it's not working ATM :frowning:
Thanks for your help

switch( ) {
    case {{ getAllAmlFailed.data.length > 0 }}:
        return "#E01E5A"
    case {{ getAllAmlFailed.data.length > 1 }}:
        return "#2EB67D"
    case {{ getAllAmlFailed.data.length > 1 }}:
        return "#116EE3"


Hey there :wave: What component are you looking to change the color on?