Question

6.1.6: JavaScript practice. The JavaScript code below initializes the variable tvShow to a popular TV show....

6.1.6: JavaScript practice.

The JavaScript code below initializes the variable tvShow to a popular TV show. Then, an if statement displays a message in the console if tvShow is null, otherwise the value of tvShow is displayed in the console. Change the code to prompt the user for the user's favorite TV show. Then, display "____ is your favorite TV show!" in the console. Press "Run JavaScript" to run your code.

Note: The console will display an error message if the JavaScript interpreter detects a syntax error. A syntax error is the incorrect typing of a programming statement. Ex: Forgetting to place "quotes" around a string value is a syntax error.

1 Use prompt to get the user's favorite TV show
2 var tvShow = "Sherlock";

3

4 if (tvShow === null) {

5 console.log("You did not enter a TV show.");
6 }
7 else {
8 console.log(tvShow);
9 }

10

Run Javascript Reset code

Your console output

sherlock

6.1.1: prompt() and console.log().

Start

Write a statement that displays: 3 2 1 Go!

1

2

3

/* Your solution goes here */

1

2

3

Check

Next

0 0
Add a comment Improve this question Transcribed image text
Answer #1

`Hey,

Note: If you have any queries related the answer please do comment. I would be very happy to resolve all your queries.

1)

var tvShow = prompt("Enter tv show: ","");
if (tvShow === null) {
console.log("You did not enter a TV show.");
}
else {
console.log(tvShow+" is your favorite TV show!");
}

Note: Brother According to Chegg's policy we are only allowed to answer first part if there are many. So, I request you to post other part as separate posts

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
6.1.6: JavaScript practice. The JavaScript code below initializes the variable tvShow to a popular TV show....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT