How can I display a one time alert? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 1

How can I display a one time alert?

I am a thirteen years old programmer and android apps developer. I started coding at the age of twelve. Now I have been creating apps and my own blogs. So, I want to know if there is a way through which I can display an one time alert in my app using JavaScript. I have done it by adding the code: alert('Hello world'); But every time the users visit the app they see this text. So I want to get your help that I may show this text only for the first time.

9th Aug 2021, 9:34 AM
Onan Basnet
Onan Basnet - avatar
2 ответов
+ 3
Try this using local storage to store status const greeting = 'greeting'; const greetingText = 'Hello world'; if(!localStorage.getItem(greeting)) { localStorage.setItem(greeting, greetingText); alert(greetingText); }
9th Aug 2021, 2:39 PM
Calviղ
Calviղ - avatar
+ 1
Calvin I'm greatly thankful to you for your help. You are lovely. Thanks for your help. Stay home, Stay safe and Stay Genius 😊😊☺️
9th Aug 2021, 3:25 PM
Onan Basnet
Onan Basnet - avatar