+ 1
JS qna bot code help
I'm trying to make a JS qna bot that answers questions about a specific topic. I'm trying to get it to check for a possible question keyword, In this example: Keywords: how many beans | number of beans // line 53 If user enters one of the above, Answer = "800 beans" // line 108 var PQ1 = /how many beans|number of beans/; var PA1 = PQ1.test(input.toLowerCase()); switch (input.toLowerCase()){ case PA1: Ans = "800 beans"; break; } The problem is it doesn't work. Cuz PA1 returns a value of true (or 1). Instead of the string that is found in PQ1. https://code.sololearn.com/Wi4hy9HIJ3nc/#js
4 Respuestas
+ 1
Ginfio
I have a bot code where I check text in input and then respond accordingly .
Check if it helps.
https://code.sololearn.com/WxuNmwss4QWD/?ref=app
+ 1
If you win PA1 to hold the string of PQ1, why are you using test?
+ 1
JME wait, wut?
PA1 // possible answer 1,
is testing if any of the steings in PQ1 match the input value.
+ 1
Divya Mohan It does help.
Thank u so much.