Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to check my javascript code

function CalculateCGPA(){
       
        var os=document.getElementById("t1").value;
        if(os="")
        os=0;
        
        var gs=document.getElementById("t2").value;
        if(gs="")
        gs=0;
        var dc=document.getElementById("t3").value;
        if(dc="")
        dc=0;
        var xus=document.getElementById("t4").value;
        if(xus="")
        xus=0;
        var abd=document.getElementById("t5").value;
        if(abd="")
        abd=0;
        document.getElementById("g1").innerHTML=letterGrade(os);
        document.getElementById("g2").innerHTML=letterGrade(gs);
        document.getElementById("g3").innerHTML=letterGrade(dc);
        document.getElementById("g4").innerHTML=letterGrade(xus);
        document.getElementById("g5").innerHTML=letterGrade(abd);
        var cgpa=(4*gradeWeight(os)+4*gradeWeight(gs)+4*gradeWeight(dc)+4*gradeWeight(xus)+4*gradeWeight(abd))/20;
        document.getElementById("2001").innerHTML=document.write(cgpa);










    }
    function letterGrade(mark){
        mark=parseInt(mark);
        if(mark>=90)
        mark='A';
        if(mark>=85)
        mark='A-';
        if(mark>=80)
        mark='B+';
        if(mark>=75)
        mark='B';
        if(mark>=70)
        mark='B-';
        if(mark>=65)
        mark='C+';
        if(mark>=60)
        mark='C';
        if(mark>=56)
        mark='C-';
        if(mark>=53)
        mark='D+';
        if(mark>=50)
        mark='D';
        if(mark>=40)
        mark='D-';
        if(mark<=39.9)
        mark='F';




    }
    function gradeWeight(mark){
        if(mark>=90)
        mark=4.0;
        if(mark>=85)
        mark=3.7;
        if(mark>=80)
        mark=3.3;
        if(mark>=75)
        mark=3.0;
        if(mark>=70)
        mark=2.7;
        if(mark>=65)
        mark=2.3;
        if(mark>=60)
        mark=2.0;
        if(mark>=56)
        mark=1.7;
        if(mark>=53)
        mark=1.3;
        if(mark>=50)
        mark=1.0;
        if(mark>=40)
        mark=0.7;
        if(mark<=39.9)
        mark=0.0;





    }


    document.getElementById("butn1").addEventListener("click", CalculateCGPA);
</script>
</html>
Source by jshint.com #
 
PREVIOUS NEXT
Tagged: #check #javascript #code
ADD COMMENT
Topic
Name
8+8 =