# Thread: if statment with with a condition of 4 or not working

1. ## 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

Code:
```// Ex: 3-1 Grading Work
var goal;

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

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

{

if( goal > 70 )
{
}

else if( goal > 60 )
{
}
else if( goal > 50 )
{
}
else if( goal > 40 )
{
}
else if ( goal < 40 )
{
}
else if ( goal < 40 )
{
}
}

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

2. 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.

Code JavaScript:
```// Ex: 3-1 Grading Work
var goal  = prompt('Please input the goal(%)'),
goal  = parseInt(goal, 10),

if (goal >= 0 && goal <= 100) {
if (goal > 70) {
} else if (goal > 60) {
} else if (goal > 50) {
} else if (goal > 40) {
} else {
}

} else {
}```

3. 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:
Code JavaScript:
`if (goal >= 0 && goal <= 100)`

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

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•