A live implementation of a chatbot
Written by - Millan Kaul
How to build and test your own chatbot (no internet needed…) - a live demo.
This is a sample page demonstrating how a simple chatbot can work using basic string operations and keyword search. It uses no AI language techniques just match queries with relevant information from a fixed source of blog knowledge.
Understanding JavaScript Closures
JavaScript closures are functions that have access to variables from another function’s scope. This is often used to create private variables or functions in JavaScript.
For example:
function outer() {
let count = 0;
return function inner() {
count++;
console.log(count);
}
}
Here, the inner function remembers the environment where it was created.
A Guide to Flexbox CSS
Flexbox is a powerful layout module that helps distribute space and align items in a container, even when their size is unknown or dynamic.
Key properties include justify-content
, align-items
, and flex-direction
.
Example:
.container {
display: flex;
justify-content: center;
align-items: center;
}
Introduction to Async/Await in JavaScript
Async/Await syntax in JavaScript allows writing asynchronous code that looks synchronous, making it easier to read and debug.
Example:
async function fetchData() {
try {
let response = await fetch('https://api.example.com/data');
let data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
}
Markdown Basics for Blogging
Markdown is a lightweight markup language with plain text formatting syntax, designed to be easy-to-read and easy-to-write.
Headers use the #
symbol, lists use -
or *
, and code blocks are wrapped in triple backticks ```
.
Example:
# This is a header
- List item 1
- List item 2
```js
console.log('Code block');
```
Understanding Event Loop in JavaScript
The event loop is a fundamental concept to understand asynchronous programming in JavaScript.
It allows the JavaScript engine to perform non-blocking operations by offloading operations to the system kernel whenever possible.
When asynchronous operations complete, the event loop picks up the callback functions and executes them.
Full source code on GitHub