JSFiddle - React, Tailwind, and code Playground

by webchemist

HTML

<table id='truth'>
<tr>
    <th>F</th>
    <th>H</th>
    <th>P</th>
    <th>S</th>
    <th>T</th>
    <th width="50"></th>
    <th style="color:green;">Normal Gates</th>
    <th style="color:red;">NAND Only</th>
    <th style="color:purple;">Failures</th>
    <th style="color:blue;">NAND Failures</th>
</tr>
</table>

JavaScript

$(document).ready(function(){
    truthTable();
});

function failingNors(f,h,p,s,t){
    var ff = norGate(f,f);
    var hh = norGate(h,h);
    var pp = norGate(p,p);
    var ss = norGate(s,s);
    var tt = norGate(t,t);
    
    
    
    
    var hp = !norGate(hh,pp);
    var st = !norGate(ss,tt);
    var sp = !norGate(ss,pp);
    if(
        norGate(
            !norGate(
               !norGate(
                    !norGate(
                        norGate(ff,hp)
                       ,norGate(ff,sp)
                    )
                   ,norGate(tt, hp)
                )
               ,norGate(ff,st)
            )
       ,norGate(hh,st)
        )
       
      ){
        return 1;
    }
    return "";
}


function norOnly(f,h,p,s,t){
    if(!norGate(
        norGate(
            norGate(
                 !norGate(
                     norGate(!f,!h)
                    ,norGate(!f,!s)
                 )
                ,norGate(!h,!t)
             )
            ,!p
         )
        ,norGate(
             !norGate(!s,!t)
            ,norGate(f,h)
        )
    )){
        return 1;
    }
    return "";
}



function normalGates(f,h,p,s,t){
    if(orGate(
        andGate(
            orGate(
                 orGate(
                     andGate(f,h)
                    ,andGate(f,s)
                 )
                ,andGate(h,t)
            )
           ,p
          )
    ,andGate(
         andGate(s,t)
        ,orGate(f,h)
        )
    )){
        return 1;
    }
    return "";
}

function failingGates(f,h,p,s,t){
    if(
           (f && h && p)
       ||  (f && s && p)
       ||  (h && t && p)
       ||  orGate(
                (f && s && t)
               ,(h && s && t)
           )
      ){
        return "";
    }
    return 1;
}


function notGate(a){
    if(a){
        return false;
    }
    return true;   
}
         
function orGate(a, b){
    if(a || b){
        return true;
    }
    return false;   
}   

function andGate(a, b){
if(a &&...