Question:
I was wondering how I could have a user input something and save it to the code so that when another person runs it they can see the others post
Current behavior:
Desired behavior
Repl link:
code snippet
Question:
I was wondering how I could have a user input something and save it to the code so that when another person runs it they can see the others post
Current behavior:
Desired behavior
Repl link:
code snippet
For basic input, in Replit’s JavaScript (and Replit’s version of NodeJS, but not actual NodeJS) you can use prompt(string);
as a very basic way of getting user input.
To save it so another person could see it, you would need a database. You could use NodeJS and Replit’s database to do this pretty easily.
// init Replit database
const Client = require("@replit/database");
const db = new Client();
// print the last message
console.log("The last message was:", await db.get("last_message"));
// get user input
const input = prompt("Enter some text ");
// store it in the database
db.set("last_message", input);