In: Computer Science
How do you write this code in JavaScript inside the head?
The javascript code for this is
code in screenshot
code:
<!DOCTYPE html>
<html>
<head>
<title>
my solution
</title>
<script>
//asking user to enter first name
and saving in a variable firstname
firstname= window.prompt("Enter
First Name");
//asking user to enter last name
and saving in a variable lastname
lastname= window.prompt("Enter Last
name");
//alerting the names separated by
space and end with a short message "welcoeme to java script"
alert(firstname+" "+lastname+"
welcome to javascript")
</script>
</head>
<body>
</body>
</html>
Output:
prompts user to enter first name
prompts user to enter last name
alerting first name followed by space then last name and a message welcome to javascript