If statment with with a condition of 4 or not working

Hi I am trying to do an if statment that check
if value more or equal to 0 or less or equal to 100 to work but it only accepts part of the condition

here my code

// Ex: 3-1 Grading Work
var goal;
var grade;
grade = "Not Yet Graded";

goal = prompt( "Please input the goal(%)" );
goal = parseInt( goal, 10 ); // see comment



if ((goal ==100 || goal > 100) || (goal < 0 || goal === 0))

{
	
	if( goal > 70 )
	{
		grade = "First Class";
		alert( "goal: " + goal + "% - Grade: " + grade );
	}

	else if( goal > 60 )
	{
		grade = "2.1";
		alert( "goal: " + goal + "% - Grade: " + grade );
	}
	else if( goal > 50 )
	{
		grade = "2.2";
		alert( "goal: " + goal + "% - Grade: " + grade );
	}
	else if( goal > 40 )
	{
		grade = "Third Class ";
		alert( "goal: " + goal + "% - Grade: " + grade );
	}
	else if ( goal < 40 )
	{
		grade = "Fail";
		alert( "goal: " + goal + "% - Grade: " + grade );
	}
	else if ( goal < 40 )
	{
		grade = "Fail";
		alert( "goal: " + goal + "% - Grade: " + grade );
	}
}

else
{
	alert( "Invalid goal, outside range 0-100" );
}


The current way your code is setup won’t work as your if statement is always expecting to see a value less than 0 or greater than 100, see the below which is the same code above but more simplified and work from my tests.

// Ex: 3-1 Grading Work
var goal  = prompt('Please input the goal(%)'),
    goal  = parseInt(goal, 10),
    grade = 'Not Yet Graded';

if (goal >= 0 && goal <= 100) {
    if (goal > 70) {
        grade = 'First Class';
    } else if (goal > 60) {
        grade = '2.1';
    } else if (goal > 50) {
        grade = '2.2';
    } else if (goal > 40) {
        grade = 'Third Class';
    } else {
        grade = 'Fail';
    }
    
    alert('goal: ' + goal + '% - Grade: ' + grade);
} else {
    alert('Invalid goal, outside range 0-100');
}

Hi,

Your problem is in first if statement where you are checking if goal

  1. is equal to one hundred, or
  2. is greater than 100, or
  3. is less than zero, or
  4. is equal to zero

As for example, 1000 is greater than 100 (check 2.) it lets this number through.
It then checks if 1000 is greater than 70 (which it is) and then alerts that you have a first class grade.

It would be better to write this first if statement as:

if (goal >= 0 && goal <= 100)

Hi guys thanks so simple was pulling my hair out, thanks alot guys