Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const CONFIG = {
- TEXT_OF_MESSAGE: "Hello, world!",
- PEER_IDENTIFIER: 0,
- MESSAGE_IDENTIFIER: 0,
- TIMEOUT_EDIT_MESSAGE: 1000
- }
- let index = 0;
- let timeoutIdentifier = 0;
- let editTheMessage = (message) => {
- // editing a message function
- console.log(message);
- }
- // stop script function
- let stopScript = () => clearTimeout(timeoutIdentifier);
- let main = () => {
- let currentMessage = CONFIG.TEXT_OF_MESSAGE.slice(0, index);
- editTheMessage(currentMessage);
- index = (index + 1) % CONFIG.TEXT_OF_MESSAGE.length;
- timeoutIdentifier = setTimeout(main, CONFIG.TIMEOUT_EDIT_MESSAGE);
- }
- main();
Advertisement
Add Comment
Please, Sign In to add comment