Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Running into trouble with some javascript on one of my labs.Thanks for your time

ID: 669405 • Letter: R

Question

Running into trouble with some javascript on one of my labs.Thanks for your time.

Write a script in the sandbox that prompts the user to enter their first name and their last name. Use two different prompt dialog boxes to acquire the data. If the user does not provide a string response to the firstprompt, do not request the last name.

Use the user's input to create a string to say hello to the user.
Be sure to capitalize the user's full name, but not the "Hello, " part of the string.

Write the user's actual input to the console.

Error trap as needed.

Explanation / Answer

<!DOCTYPE html>
<html>
<head>
   <title></title>
<script type="text/javascript">
   function myfunction()
   {
       var first_name=prompt("Enter first name");
       if(first_name)
       {
           var last_name=prompt("Enter last name");

           alert("Hello "+first_name.toUpperCase()+" "+last_name.toUpperCase());
           console.log(first_name);
           console.log(last_name);
       }
   }
</script>
</head>

<body>

</body>
</html>