Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis+ 1
Making a JS bot thatāll answer questions about a specific topic. need suggestions, advice..
Example: Topic: sololearn. input: how many users on sololearn. And in my JS code Iāll do it like: if (input == āhow many users on sololearn || input == āhow many users are there on sololearnā || input == ānumber of users on sololearnā || how many users on SoloLearnā ) {answer = ā######} if (input == āwho made sololearnā || input == āwho created sololearnā || input == āwho developed sololearnā) {answer = āname...ā } Thatās my way. If you have an idea on how to make it easier, please let me know.
6 Respostas
+ 1
Check this I have tried using regex.
https://code.sololearn.com/WGtE4kjlbi30/?ref=app
+ 1
As you can see Iām using if for every different way of asking the same question. (I could also use switch)
So, if you have any ideas, suggestions to simplify the work or amount of code, let me know know.
Thank.You()
+ 1
Use regex
If question string contain many/number followed by users
Ans =#####
If question string contain made/created/develop followed by sololearn
Ans =name.
Hope it will help you.
+ 1
Divya Mohan thanks, that does help.
And what does the regex code look like.
use āmadeā, ācreatedā for example. What does the code look like when put with regex?
Iām not very familiar with regex
+ 1
If you are not the interested in regex. Use .search() method for string to find sub string.