let level = 0;
let usersName;
let path;
const getBotReply = (msg) => {
if (level === 0) {
level = 1;
usersName = msg;
return "Chur " + usersName + ". Do you live in Raglan?";
}
if (level === 1) {
level = 2;
if (msg === "yes") {
path = "left-yes";
return "Do you know how to surf?";
}
if (msg === "no") {
path = "right-no";
return "Are you from Auckland?";
}
}
Basically I want it so that instead of typing yes or no. The user will type reset and it will return to "level 0"
I've tried:
if (msg === "reset") {
level = 0;
}