Comments (1)
Hi.
You can add if
and else if
statements in script.js.
Type this into script.js:
if (prompt.toLowerCase().trim().replace(/\s+/g, ' ').replace("?", '').replace("'", '') .replace("ur", "your")=== "whats your name") { typeText(messageDiv, "My name is ChatBot"); return; }
What this does is it takes whatever the input the user gives and then it turns it into lowercase, then it removes extra spaces like if they accidently put two spaces. then it removes the question mark, then it removes an apostrophy, then it replaces "ur" with "your", and finally if after doing all of this ; the input is "whats your name", it will say "My name is ChatBot"
its very rare that someone says "whattcha name" or something other than whats your name to a chatbot but if you really want you can put or operators. In javascript, or operators are written like this ||
if (prompt.toLowerCase().trim().replace(/\s+/g, ' ').replace("?", '').replace("'", '') .replace("ur", "your")=== "whats your name" || prompt.toLowerCase().trim().replace(/\s+/g, ' ').replace("?", '').replace("'", '') .replace("ur", "your")=== "whattcha name"
similarily you can add more or operators using ||
and it will always give back the same output that is inside the if function.
As for the age problem, you can add more else if
statements for example
else if (prompt.toLowerCase().trim().replace(/\s+/g, ' ').replace("?", '').replace("'", '').replace("ur", "your") === "whats your age") { typeText(messageDiv, "I have no age, i am an immortal being!"); return; }
Make sure your indentation is correct.
Hope this helps!
from project_openai_codex.
Related Issues (20)
- POST http://localhost:3000/ 500 (Internal Server Error) HOT 1
- Chat got 4 or 3.5 turbo models not supported
- POST http://localhost:5173/ 404 (Not Found) HOT 1
- Program not working after copying the exact same code as in Github. HOT 1
- Request failed with status code 429 HOT 6
- Chatbot doesn't remember previous chats and also giving answer of the question when i asked about today's date. it gives answer 11th August,2020 but today is 22nd April,2023 HOT 1
- User. Svg expected js
- 404 Error HOT 1
- Why does the client send the POST to 'https://codex-im0y.onrender.com/'? HOT 1
- KeyCode is deprecated
- Conversation Is Not Saved HOT 3
- Urgent Error facing Localhost:5173 says ~~~~~ HOT 4
- API KEY NOT GETTING RECOGNISED
- POST http://localhost:5173/ 404 (Not Found) HOT 1
- Not getting the result,could anyone solve this issue HOT 2
- Error 401
- api is not working and chat gpt tells about this error is your exceeding the api limit HOT 2
- folder is not copying
- 'openai' does not provide an export named 'Configuration' 🥲 HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from project_openai_codex.