Issue
I need some help in this conditional code.
In order to store the required data to the variable paw, I have three conditions.
- If
nameuis not blank or empty andempiduis blank or empty, it should store theTitle : nameuonly. - Else if
nameuis blank or empty andempiduis not blank or empty, it should store theEmpID : empiduonly. - Else store both.
I have written the code myself, but it is not working. Here is the code :
var paw = "";
if(nameu !== " ") {
paw = JSON.stringify({
Title: nameu
});
}
else if(nameu === "" & empidu !== " ") {
paw = JSON.stringify({
EmpID: empidu
});
}
else {
paw = JSON.stringify({
Title: nameu,
EmpID: empidu,
});
}
Note : nameu (String) and empidu (number) are user input values
I think I am either writing wrong statements or logic. Please help me.
Solution
You should use logical AND operator (&&) to evaluate multiple expressions instead of bitwise AND (&)
Answered By - A_Al3bad Answer Checked By - Timothy Miller (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.