java script assignment - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

java script assignment

jaynesmyjaynesmy Posts: 5Member

I am new to Javascript and trying to write this script that prompts a user for first and last name and then greets them. I have tried this and I am not sure if it is the best way to do it. It seems to work but it does not space the name. Any help would be appreciated. Thanks!

Home Page

var who1=prompt("What is your first name?");
var who2=prompt("What is your last name?");

function greeting(who1,who2){
answer = who1+who2;
return answer;

document.write("Welcome to my site " +greeting(who1,who2));


Sign In or Register to comment.