+ 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 Antworten
+ 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.