Hello,
I have this code for a popup, and part of it includes an arcade expression to change the value, but my code is not working. I’m just starting to learn JavaScript right now, so I’m not very advanced in it. Thanks!
//popup for Intersection
const IntersectionPopupTemplate = {
// You can dynamically set the title, e.g., the block's name
title: "Holiday Embargo (Intersection)",
content: [
{
type: "fields",
fieldInfos: [
{
fieldName: "OnStreetName",
label: "Cross Street 1"
},
{
fieldName: "FromStreetName",
label: "Cross Street 2"
},
{
fieldName: "BoroughCode",
label: "Borough",
format: {
expression: `
var borough = $feature['BoroughCode'];
return (borough == "M") ? 'Manhattan' :
(borough == "X") ? 'Bronx' :
(borough == "B") ? 'Brooklyn' :
(borough == "Q") ? 'Queens' :
(borough == "S") ? 'Staten Island' : 'n/a';
`
}
}
]
}
]
};
Use the When function instead of the ternary operator
var borough = $feature['BoroughCode'];
When(borough == "M", 'Manhattan',
borough == "X", 'Bronx',
borough == "B", 'Brooklyn',
borough == "Q", 'Queens',
borough == "S", 'Staten Island',
'n/a')