Lo que tengo que hacer es muy simple. Necesito configurar el valor PV1-2.1 si el valor PV1-18.1 recibido está en una lista de valores. Establecí mi variable en una matriz de esos valores, pero la comprobación no parece funcionar
var type = ['YB','ES','EO','SO','CX'] if msg['PV1']['PV1.18']['PV1.18.1'] = type { msg['PV1']['PV1.2']['PV1.2.1'] = 'V'; }Debería intentar escribir su condición como:
if(type.includes(msg['PV1']['PV1.18']['PV1.18.1'])){ msg['PV1']['PV1.2']['PV1.2.1'] = 'V'; }Puede intentar recorrer la matriz y comparar con cada elemento:
var type = ['YB','ES','EO','SO','CX']; var i = type.length(); while (i--){ if (type[i] == msg['PV1']['PV1.18']['PV1.18.1']){ msg['PV1']['PV1.2']['PV1.2.1'] = 'V'; } }