View Full Version : Returning Variables in Alerts

08-04-2002, 06:15 PM
I'm making something that asks for your name (prompt) and then says 'Hey so-and-so' via alert.

var x = prompt("What's your name/nickname?")
alert("Hey document.write(x)!")

It doesn't carry out the command. It says it how it is. How do I get it to say the variable in the alert?

08-04-2002, 06:36 PM
var x = prompt("What's your name/nickname?", "");
alert("Hey "+x+"!");