JSFiddle - React, Tailwind, and code Playground

JavaScript

function ab(p){
       a=1;
       if(p){
           a=2
           alert(a)
       }
       alert(a)
   }

ab(true);
 alert(a);