alien4u
06/06/2018, 2:29 PMerictgrubaugh
06/06/2018, 2:35 PMerictgrubaugh
06/06/2018, 2:35 PMnull
?erictgrubaugh
06/06/2018, 2:37 PMif (A && B) {
data[key] = A ? oneThing : null;
}
In order to even execute your ternary statement, A
has to be `true`; it will never be anything else, so the ternary will always return oneThing
erictgrubaugh
06/06/2018, 2:38 PMalien4u
06/06/2018, 2:39 PMdata[key] = results[map[key]] ? results[map[key]][0].value : null;
Look like I dont understand this entirely I would check to understand it better...erictgrubaugh
06/06/2018, 2:55 PMresults[map[key]][0] ?
(add the [0]
)alien4u
06/06/2018, 3:10 PMdata[key] = results[map[key]].length ? results[map[key]][0].value : results[map[key]];
Or this:
data[key] = results[map[key]][0] ? results[map[key]][0].value : results[map[key]];
I don't get the Booleanserictgrubaugh
06/06/2018, 3:11 PMalien4u
06/06/2018, 3:12 PMerictgrubaugh
06/06/2018, 3:12 PMresults[map[key]]
will never go through that ternary statement at all because it doesn't have a length
property, so your if
will be false and it will go through the else
alien4u
06/06/2018, 3:13 PMalien4u
06/06/2018, 3:13 PMerictgrubaugh
06/06/2018, 3:14 PMalien4u
06/06/2018, 3:15 PMfor (var key in map) {
if (results[map[key]]) {
data[key] = results[map[key]].length ? results[map[key]][0].value : data[key] = results[map[key]];
}
}
erictgrubaugh
06/06/2018, 3:15 PMmap
to pull out the elements themselves or for any elements that are Arrays, grab the value
property from the first elementalien4u
06/06/2018, 3:16 PMerictgrubaugh
06/06/2018, 3:16 PMfor (var key in map) {
if (util.isArray(results[map[key]])) {
data[key] = results[map[key]][0].value;
} else {
data[key] = results[map[key]];
}
}
erictgrubaugh
06/06/2018, 3:17 PMfor (var key in map) {
var result = results[map[key]];
data[key] = util.isArray(result) ? result[0].value : result;
}
alien4u
06/06/2018, 3:17 PMerictgrubaugh
06/06/2018, 3:18 PMN/util
module is always loaded anywayalien4u
06/06/2018, 3:18 PMerictgrubaugh
06/06/2018, 3:19 PMutil
and log
erictgrubaugh
06/06/2018, 3:19 PMalien4u
06/06/2018, 3:19 PMerictgrubaugh
06/06/2018, 3:20 PMalien4u
06/06/2018, 3:22 PMalien4u
06/06/2018, 3:23 PMerictgrubaugh
06/06/2018, 3:24 PMerictgrubaugh
06/06/2018, 3:24 PMerictgrubaugh
06/06/2018, 3:25 PM