Skip to content

Latest commit

 

History

History
50 lines (36 loc) · 774 Bytes

outputs-and-variables.md

File metadata and controls

50 lines (36 loc) · 774 Bytes

Creating Popups and Variables

Create different types of popups

Create a popup with some text

alert("hello");

Give users some information

alert("you win!");
alert("you lose!");

Add some numbers together and show the result

alert(2 + 2);

Add some words together

alert("hello " + "everyone!");

Saving a value as a variable

Save the sentence as a variable and display its value

var hello = "hello world";
alert(hello);

Display a popup that asks for an answer

prompt("Enter a secret word");

Display the popup again and save the answer as a variable

var answer = prompt("Guess a letter");
alert(answer);