Running into trouble with some javascript on one of my labs.Thanks for your time
ID: 669328 • 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.
Copy the script into a JavaScript file named sayHello.js.
Explanation / Answer
<script type="text/javascript">
function getStringInput(){
var myString = window.prompt('Enter First Name Please!','');
if(!myString){
return
}
else
{
console.log(myString);
var myString1 = window.prompt('Enter Last Name Please!','');
if(!myString1){return}
else{
console.log(myString1);
myString=myString + " " +myString1;
var res = myString.toUpperCase();
console.log(res);
alert("Hello "+res);
return
}
}
}
</script>
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.