1

I have a list of 4 phone's and I am using OR operator but it is not working properly

this is my code

app.intent(SHOW_PHONE_INTENT, (conv) => {
  conv.contexts.set(AppContexts.AWAITING_PHONE, 1);
  conv.ask("Here's the list of phone's.");
  conv.ask(new List(PhoneList));
});

app.intent(SELECTED_PHONE_INTENT, (conv, input, option) => {
    const context = conv.contexts.get(AppContexts.AWAITING_PHONE);
    conv.contexts.set(AppContexts1.AWAITING_REPLY, 1, {phone: option});

    if (option === 'Phone1' || 'Phone2'){
      conv.ask(`${option} is in stock. Do you want to add it to your cart.`); 
    } else if (option === 'Phone3'){
      conv.ask(`${option} is out of stock. Would you like to order other products`);
    } else if (option === 'Phone4'){
      conv.ask(`${option} will be launched 1 week later. Would you like to register for this`);
    }
});

but when I select Phone4 or Phone3 then also it is returning response of option1

conv.ask(`${option} is in stock. Do you want to add it to your cart.`);

Am I doing something wrong

Falcon
  • 55
  • 5

1 Answers1

2

please change the conditional statement to this .

if (option === 'Phone1' || option === 'Phone2')
YouBee
  • 1,981
  • 1
  • 15
  • 16