Check if the variable/key exist

后端 未结 1 760
暖寄归人
暖寄归人 2021-01-16 23:15

I have a value customer with different condition :

  • if customer = yes then score = 10
  • if customer = no then score = 5
  • if customer is null then
1条回答
  •  执笔经年
    2021-01-16 23:48

    You did not check null for customer

         var customer = 
    json.fields.customer != null && json.fields.customer.length > 0 ? json.fields.customer[0].value : null;  
    

    0 讨论(0)
提交回复
热议问题