Following Up this Question
trying to get the value of the struct inside an array
Where i had an accepted answer, I am trying to get the value if the array is defined...
so if the name is "form", get the details of the value
The Code
but my structure is like this
<cfscript>
x = [];
x[1] = {};
x[1]["name"] = "form";
x[1]["value"] = "100";
writedump(x);
</cfscript>
<cfset formIndex = ArrayFind(x, function(st){
return st.name == "form";
})>
<cfif formIndex eq 1>
<cfset value = x.filter((item) => ( item.value) )>
</cfif>
<cfdump value="#value#">
<cfdump var="#formindex#">
as i have to check form the name = "form" and then only i need to get the value of value field, else it should return me 0
This looks like a use of the ternary operator.
<cfscript>
x = [];
x[1] = {};
x[1]["name"] = "form";
x[1]["value"] = "100";
formIndex = x.find((st) => (st.name == "form"));
result = formIndex ? x[formIndex].value : 0
</cfscript>