This is most adventures feature in computer languages compare values.
About IF:
If anybody ask your cvv number, Don't give it.
Hear you got doubt what is cvv number, Flip your ATM card you can found cvv number.
Hear you can found two statements one is
1 statement:If anybody ask your cvv number:is rule
2 statement:Don't give it: is action
if statement in javacript:
if(a==1) window.alert("Found a 1:");
First it checks the condition if equal(a==1)
then message to user Found a 1:
if(a==1){
window.alert("Found a 1:");
}
Understand above code:
It checks value in variable "a", if "a: contains number 1 then message to user Found a 1:
if not message will not displayed. That is "Found a 1".
Conditional Operators:
Condition statement uses it's own conditional operator [==,<,> these are called operators]
A conditional expression usually includes two values like this
if(a==1)----> Hear "a" and "1" are two values.
These values can be variables, Constants.
Below operators will tell you how to compare two values
== Is equal to
!= Is not equal to
< Is less than
> Is greater than
>= Is greater than or equal
<= Is less than or equal to
Combing conditional operators and Logical
operators:
If we don't use Logical operators what happens see below
if(state == " ") window.alert("error");
if(email==" ") window.alert("error");
Using a logical operator we can combine above two statements
if(state ==" " || email==" ") window.alert("error");
This is called "||" OR operator.
how to use ||
A:
if(state ==" " || email=="abc@gmail.com") window.alert("That's OK");
B:
if(state =="Detroit " || email==" ")
window.alert("That's OK");
If we don't use Logical operators what happens see below
if(state == " ") window.alert("error");
if(email==" ") window.alert("error");
Using a logical operator we can combine above two statements
if(state ==" " || email==" ") window.alert("error");
This is called "||" OR operator.
how to use ||
A:
if(state ==" " || email=="abc@gmail.com") window.alert("That's OK");
B:
if(state =="Detroit " || email==" ")
window.alert("That's OK");
Observe above two A: and B: if one condition is satisfied you will see
"That's OK" message. Either one should satisfy then only you can see
message "That's OK".
This is called smart coding single line
But sometimes both[or all] conditions should be satisfied then you can use "&&" operator.
if(state ==" " && email==" ") window.alert("error");
Observe above both conditions should satisfy then
only you can see window.alert("error");
Real time example: While filling up for new mail-id some sites not allows
leaving blanks in text boxes, they will show
"*" symbol means compulsory.
Now analyze yourself when to use OR or when to use AND operators.
Next Logical operator is!
if(!(phone = = " "))
alert("phone is ok");
Above if phone number variable contains value then only statement excuted that is alert("phone is ok "); Now you can see alert phone is ok
Alternatively you can write above condition like this
if(phone !=" ")
alert("phone is ok");
IF and ELSE:
IF YOU ARE NOT UNDERSTOOD IF CONCEPT PLEASE GO DOWN YOU CAN UNDERSTAND VERY EASILY:
http://javascriptwithshrinivas.blogspot.com/2013/06/how-to-understand-if-and-else.html
---------------------------------------------------------------
This two weeks i am dedicated this page to uttarakhand victimsNext Logical operator is!
if(!(phone = = " "))
alert("phone is ok");
Above if phone number variable contains value then only statement excuted that is alert("phone is ok "); Now you can see alert phone is ok
Alternatively you can write above condition like this
if(phone !=" ")
alert("phone is ok");
IF and ELSE:
IF YOU ARE NOT UNDERSTOOD IF CONCEPT PLEASE GO DOWN YOU CAN UNDERSTAND VERY EASILY:
AFTER READING BELOW EXPLANATION,YOU CONCLUDED THAT IT'S VERY EASY IF , Again don't add me in your fans list. I am getting mails your way of explanation is very easy and understandable. This is my new invention by telling story you can understand very easily.
i MAKE PROGRAMMING IS VERY EASY.http://javascriptwithshrinivas.blogspot.com/2013/06/how-to-understand-if-and-else.html
---------------------------------------------------------------
http://someusefulltips.blogspot.in/2013/06/person-finder-2013-uttarakhand-floods.html
No comments:
Post a Comment