Skip to main content
Added explanation and refactored.
Source Link

Below function with the object as a parameter should check if that object contains every array element as a parameter and the value of it is not falsy.

const checkKeysAndValues = (yourObject) => invoice_query_params.every(param => Object.keys(yourObject).includeshasOwnProperty(param) && yourObject[param])
const checkKeysAndValues = (yourObject) => invoice_query_params.every(param => Object.keys(yourObject).includes(param) && yourObject[param])

Below function with the object as a parameter should check if that object contains every array element as a parameter and the value of it is not falsy.

const checkKeysAndValues = (yourObject) => invoice_query_params.every(param => yourObject.hasOwnProperty(param) && yourObject[param])
added 9 characters in body
Source Link
letconst checkKeyscheckKeysAndValues = (yourObject) => invoice_query_params.every(param => Object.keys(yourObject).includes(param) && !!yourObject[param])
let checkKeys = (yourObject) => invoice_query_params.every(param => Object.keys(yourObject).includes(param) && !!yourObject[param])
const checkKeysAndValues = (yourObject) => invoice_query_params.every(param => Object.keys(yourObject).includes(param) && yourObject[param])
Source Link

let checkKeys = (yourObject) => invoice_query_params.every(param => Object.keys(yourObject).includes(param) && !!yourObject[param])