Multiple conditions in a jade conditional - if-statement

I'm a bit stumped as to why... if (data.query && data.query != '[object Object]') works
but if (data.query && data.query != ('[object Object]' || data.query != 'undefined'))
How can you have multiple conditions inside of a jade if?

Checking for typeof on the data.query for the undefined did the trick.
if (data.query && data.query != '[object Object]' || (typeof data.query !== 'undefined'))

Related

Oracle APEX 5.0: add items values to dynamic URL

I have table containing data in columns apex_page, apex_to_item, apex_with_values like this:
apex_to_page: 6010
apex_to_item: P6010_XSRCS_ID,P6010_XSVER_ID
apex_with_values: XSRCS_ID,ID
During rendering of the page I want to parse this values (URL destination, list of items to set, list of values from current page) and create URLs based on it. For example: f?p=112:6010:4314006485638::NO::P6010_XSRCS_ID,P6010_XSVER_ID:100,200&cs=3LNhUQHJiAOOaiw3C_z3bHGtc4Us0LZV-D7ZMQhG0Z3EzCLeJpT8f--YA7SFOoD4xQD2C45qrv2PVxvwBY39qBA
I.e. I want to take current values of XSRCS_ID,ID items of current page (100,200) and insert it into URL. When there is only one value to pass I have solution:
SELECT name label,
APEX_UTIL.PREPARE_URL(p_url => 'f?p=' || NV('APP_ID') || ':' || apex_page || ':' || NV('APP_SESSION') || '::NO::' || apex_to_items || ':' || NV('P' || :APP_PAGE_ID || '_' || apex_with_values), p_checksum_type => 'SESSION') apex_url
FROM ...
When there are more that one item to pass I've tried something like this:
SELECT name label,
APEX_UTIL.PREPARE_URL(p_url => 'f?p=' || NV('APP_ID') || ':' || apex_page || ':' || NV('APP_SESSION') || '::NO::' || apex_to_items || ':' || regexp_replace(apex_with_values, '([^,]+)', NV('P' || :APP_PAGE_ID || '_\1')), p_checksum_type => 'SESSION') apex_url
...
FROM ...
and it isn't worked.
Is there a way to extract values from page and insert it into URL?
You need to add coma separated values. First you need to combine all the Keys together (coma separated) and then the values also coma separated.
Here is an example
l_url := APEX_UTIL.PREPARE_URL(
p_url => 'f?p=' || l_app || ':'||apex_application.g_x01||':'||l_session||'::NO::'
||l_item_item1|| ','||l_item_item2||
','||l_item_item3||','||l_item_item4||':'
||apex_application.g_x02|| ','||apex_application.g_x03||','||
apex_application.g_x04||','|| apex_application.g_x05,
p_checksum_type => 'SESSION');
htp.p(l_url);

if or statement unexpected token

I've attempting to write an in or statement, and in all honesty have never used one before. I'm trying to use the following snippet of code:
$(document).ready(function () {
if(window.location.href.indexOf("invt") > -1 || window.location.href.indexOf("shopcart") > -1)) { // if URL contains invt or shopcart
$('#carriage-promo').prop('id','newid');
}
});
But it keeps returning errors no matter what I try!
Any suggestions?
( ) are unbalanced.
if(window.location.href.indexOf("invt") > -1 ||
window.location.href.indexOf("shopcart") > -1)
I removed the last ) at the end of your if statement
if(window.location.href.indexOf("invt") > -1 || window.location.href.indexOf("shopcart") > -1))
You have one too many closing brackets )
Try:
if(window.location.href.indexOf("invt") > -1 || window.location.href.indexOf("shopcart") > -1)

Hierarchy of && and ||

Let's say I have this code (bool1, bool2 and bool3 are booleans [should be obvious)):
if (bool1 && bool2 || bool3)
When is this if-Statement true? So what if only bool3 is true and the other two booleans are false. So I want to know if it is equal to
if ((bool1 && bool2) || bool3)
or
if (bool1 && (bool2 || bool3))
I know I can simply put some more brackets in there, but my code would be shorter if not.
You need to check operator's precedence table for your language. For C++ it is:
http://en.cppreference.com/w/cpp/language/operator_precedence
13 && Logical AND
14 || Logical OR
bool1 && bool2 || bool3 is (bool1 && bool2) || bool3
It is not about if-statement it is about evaluating boolean expressions.

CoffeeScript String Comparison

In CoffeeScript, is there a way to simplify the following:
if(value === "something" || value === "else" || value === "wow"){}
I've tried:
if value is "something" or "else" or "wow"
But this produces the literal output of this:
if(value === "something" || "else" || "wow){}
Is there a way to check if a string is one of multiple values (OR or AND) in CoffeeScript?
I think you probably want
if value in ['something', 'else', 'wow']

Error in while((Status.health !0) && (Wolves.health !0) ) expected expression ")"

Hey i have an error in this:
while((Status.health !0) && (Wolves.health !0) )
Can anyone see what is wrong with this ?
It's syntactically incorrect.
Assuming you want to verify that the variables are not equal to zero:
while((Status.health != 0) && (Wolves.health != 0) )
I guess you mean
while((Status.health != 0) && (Wolves.health != 0) )