How to Code an Alert with a Variable Using Javascript
Part 1 of 2:
Setting Up the Variable
- Write the first line of code. Type "var username = prompt ('What is your name?');". Replace "username" with whatever you want to call your variable. Replace "What is your name?" with whatever you want to ask for.
Part 2 of 2:
Making the Alert
- Write the next line of code. Type "alert ("Hey, " + name + "!");". This line of code will add the variable "name" to the word "Hey, "(with the space at the end), and then add "!" to end the sentence (not required). For example, if the user inputs "Trevor" as the value of the variable "name", the alert will say "Heya, Trevor!". You can use any message you want, though. If your variable is "favoriteColor" and "Blue" is the value, for instance, you can have the alert say "Blue is a very nice color! "
- Add in more variables if you want. Try to make a one or two sentence biography.
Update 05 March 2020
You should read it
- Variable type in C / C ++
- Beware of deceptive and spreading malicious code via notification links of Google Alert
- Variable in C programming
- New bank trojan detection on Android Red Alert
- Google Alert is being used to spread malicious code
- Reference in C ++
- Declare variables in SQL Server
- Safe code in C #
- Variable in PHP
- 12 tips to beat sleepiness to be alert when working
- How to Use JavaScript Injections
- Use variables in Shell
Maybe you are interested
New planet appears that may have life like Earth Windows 10 Creators Update is now available for all compatible devices How to transfer browser data to Edge with just one click How to disable Windows 10 Creators Update ads How to get a new version of Windows 10 Creators Update now Attractive features on Windows 10 Creators Update