ImCasperr
ImCasperr

Reputation: 13

Javascript: Creating a variable then using it in a prompt

I am having an issue with this Guest prompt. I am trying to make it so that it sends a prompt with the default guest name and a random number for said guest. I don't think I am setting up the "guest" variable right, though I am also looking for other tips.

var guest = ("Guest" + Math.floor(Math.random() * 999999999) + 1;);
var name = prompt("Enter your chat name:" + guest);

Upvotes: 0

Views: 45

Answers (1)

Pritam Banerjee
Pritam Banerjee

Reputation: 18923

You had an extra ; in the code:

var guest = ("Guest" + Math.floor(Math.random() * 999999999) + 1);
var name = prompt("Enter your chat name:" + guest);

console.log(guest);
console.log(name);

Upvotes: 2

Related Questions