Apologies if I use the wrong semantics here, but I have a function that is going to eventually be embedded in an application, specifically FormAssembly. They allow for JS functions to be defined and then called within a page. So I drummed up the following function and unsurprisingly, it's been returning errors:
<script>
function getFormId(program) {
if (['a0s1M00000GrLrY', 'a0s1M00000GrLra', 'a0s1M00000GrLre', 'a0s1M00000GrLsl', 'a0s1M00000GrLtA', 'a0s1M00000GrLtC', 'a0s1M00000GrLtD', 'a0s1M00000GrLtE', 'a0s1M00000GrLtF'].includes(program)) {
return '76';
} else if (['1', '2', '3', '4', '5', '6', '7', '8', '9'].includes(program)) {
return '75';
} else {
return '74';
}
}
</script>
So I was trying to tweak it to test on a fiddle site like https://jsfiddle.net/ but am not sure how to adjust the code to define the function and then call it. I tried pasting the following into the JS section of the fiddle and running it, but nothing gets outputted:
function getFormId(program) {
if (['a0s1M00000GrLrY', 'a0s1M00000GrLra', 'a0s1M00000GrLre', 'a0s1M00000GrLsl', 'a0s1M00000GrLtA', 'a0s1M00000GrLtC', 'a0s1M00000GrLtD', 'a0s1M00000GrLtE', 'a0s1M00000GrLtF'].includes(program)) {
return '76';
} else if (['1', '2', '3', '4', '5', '6', '7', '8', '9'].includes(program)) {
return '75';
} else {
return '74';
}
}
getFormId('2')
If I could get help at least verifying the 'base' code or function definition is correct, that would be helpful. I'd also appreciate any help in modifying it to test in fiddle.