Question: Task 2 : Switch Statement You will create an application that asks the user to guess a name of one of the seven dwarfs You
Task : Switch Statement
You will create an application that asks the user to guess a name of one of the seven dwarfs
You will use the same workspace as Task No need to create another file. Just write your in the same index.html file.
Within the body element and after the code you wrote for Task type the following code:
Write a JavaScript function named dwarfName within the script tags that does the following:
Stores the user input as a variable.
Hint: It should not matter if the user entered all capital or lower case letters
Using a switch statement, you will display back to the end user some text depending on which dwarf name they entered. Do not use an ifelse statement!
Dwarf Name
Text to be displayed back
Bashful
Im known for my shyness.
Doc
Im known for his bossy attitude but in a good way, one that represents that of a leader.
Dopey
Im known for my quietness and my affection for Snow White.
Grumpy
Im known for my knowitall attitude and pure stubbornness.
Happy
Im known for my joyous outlook of the world and always having that smile on my face.
Sneezy
Im known for constantly sneezing.
Sleepy
Im know for my ability to fall asleep anywhere and anytime.
If the user entered anything else beside the above names, you will display back the following text and what they entered:
Sorryname they entered is not a name of the dwarfs.
This is an example of what your screen should look like if they entered a correct dwarf name:
This is an example of what your screen should look like if they entered an incorrect dwarf name:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
