FINAL-B0SS/Bixby-Capsules-Inprogress

consider rewriting this section using `some`

Opened this issue · 0 comments

https://github.com/Maljean/BixbyCapsules/blob/28d45b800601a6aa4e4ca906d75b59093b178a46/sfServices/code/TrackCase.js#L30-L34

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some

For example (untested code, as I didn't inspect what each type of the response is) (you can add "includes" if you want)

let keys_to_try = ['service_request_id', 'service_name', 'status', 'address'];
let matched = keys_to_try.some(function(key) {
    return (String(ret[i][key]) == String(serviceRequestNumber).toLowerCase());
}
matched = matched || String(serviceRequestNumber).toLowerCase() == 'all'; // the weird case

if (matched) {
... something