I am trying to put a function between if else block. below is what i imagine it would be.:
<script>
let condition=false
function function_here(event){
if(event){
condition = true;
}else if(!event){
condition = false;
}else{
condition = !condition;
}
</script>
{#each post as posts}
{#if posts.object1==="match" }
<p>HTML HERE</p>
{function_here(true)}
{/if}
{/each}
{#if condition}
<button>type1</button>
{:else}
<button>type2</button>
{/if}
if only during looping post result, if found posts.object1 match, i need to change the status of variable "condition"
however , this example return result "undefined".
How do i put function in between if block in svelte?