Question

In: Computer Science

How do you write this code in JavaScript inside the head? Prompt the user for their...

How do you write this code in JavaScript inside the head?

  • Prompt the user for their first name.
  • Remember you must save the value that the user enters so that you can use that value, therefore the prompt must be in an assignment statement.
  • Prompt the user for their last name.
  • Have an alert box pop up that contains the first name followed by a space and then the last name followed by a short message that you make up.
  • Hint: you will concatenate the value of the variable used to store the first name with a string that contains a space, them the value of the variable that contains the last name and then the string that contains the message. Variable names are not enclosed in quotes – we want the value of the variable, not the name of the variable to appear. Strings are enclosed in quotes,

Solutions

Expert Solution

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


Related Solutions

provide a JavaScript code that finds if the given word by user (prompt) is a Palindrome...
provide a JavaScript code that finds if the given word by user (prompt) is a Palindrome or no.
Write Javascript code for the function malwareFrequencies() that shows the malware analyst a prompt. The analyst...
Write Javascript code for the function malwareFrequencies() that shows the malware analyst a prompt. The analyst enters a list of malware names (separated by spaces) for each malware incident they have heard about in the last month.  Note that the same malware can be involved in multiple incidents. Your function should print those malware names and their frequencies to the screen. Sample output is shown below. Zeus 1 Emotet 3 WannaCry 2 Emotet 3 Emotet 3 WannaCry 2
(b) You will write a program that will do the following: prompt the user enter characters...
(b) You will write a program that will do the following: prompt the user enter characters from the keyboard, you will read the characters until reading the letter ‘Q’ You will compute statistics concerning the type of characters entered. In this lab we will use a while loop. We will read characters from stdin until we read the character ‘Q’. Example input mJ0*5/]+x1@3qcxQ The ‘Q’ should be included when computing the statistics properties of the input. Since characters are integers...
I need a java code Write a simple program to prompt the user for a number...
I need a java code Write a simple program to prompt the user for a number between 1 and 12 (inclusive) and print out the corresponding month. For example:   The 12th month is December. Use a java "switch" statement to convert from the number (1-12) to the month. Also use a "do while" loop and conditional checking to validate that the number entered is between 1 and 12 inclusive and if not, prompt the user again until getting the correct...
Write a java code snippet to prompt the user for the number of names they’d like...
Write a java code snippet to prompt the user for the number of names they’d like to enter. Create a new array of the size chosen by the user and prompt the user for each of the names. Output the list of names in reverse order.
Write the complete code necessary to prompt the user for 4 sequential numbers, calculate the summation...
Write the complete code necessary to prompt the user for 4 sequential numbers, calculate the summation of the 4 numbers and display the results including the words "The summation of 1,2,3,4 is". A summation is defined as n + n+1 + n+2.... Declare necessary variables and be sure to include comments. Include int main(void) { Code goes here } The programming language is C in Visual Basic
C++ Code Writing prompt: Grade Calculation: Write a program that asks the user to enter in...
C++ Code Writing prompt: Grade Calculation: Write a program that asks the user to enter in a number greater than or equal to zero and less than or equal to 100. If they do not you should alert them and end the program. Next, determine the letter grade associated with the number. For example, A is any grade between 90 and 100. Report the letter grade to the user.
Python Code: Write a program to prompt the user to enter a first name, last name,...
Python Code: Write a program to prompt the user to enter a first name, last name, student ID, number of hours completed and GPA for 5 students. Use a loop to accept the data listed below. Save the records in a text file. Write a second program that reads the records from your new text file, then determines if the student qualifies for Dean’s list or probation. Display the records read from the file on screen with appropriate headings above...
Write the below code to use HTML and JavaScript. 1. a) Write a JavaScript program to...
Write the below code to use HTML and JavaScript. 1. a) Write a JavaScript program to display the current day and time. b) Write a JavaScript program to print the contents of the current window.   c) Write a JavaScript program where the program takes a random integer between 1 to 10 d) Write a JavaScript program to calculate multiplication and division of two numbers (input from the user). e)Write a JavaScript program to create a new string from a given...
IN JAVA PROGRAMMING Write a complete Java program to do the following: a) Prompt the user...
IN JAVA PROGRAMMING Write a complete Java program to do the following: a) Prompt the user to enter the name of the month he/she was born in (example: September). b) Prompt the user to enter his/her weight in pounds (example: 145.75). c) Prompt the user to enter his/her height in feet (example: 6.5). d) Display (print) a line of message on the screen that reads as follows: You were born in the month of September and weigh 145.75 lbs. and...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT