Question: Create a JavaScript file named as your student ID (101010101.js) and perform following: a) Create an array of names and populate it with 3 names,
Create a JavaScript file named as your student ID (101010101.js) and perform following:
a) Create an array of names and populate it with 3 names, first one being your name:
i.e: [John, May, Jessica];
b) Create an array of phrases and populate it with 6 phrases of your choice
i.e: phrasesArray = [is very happy, is at home, is tired,];
c) Using loop, prompt user to enter a new name that doesnt already exist in names array. Do not accept empty string as valid input:
a. Append the new name to the end of names array
b. User should be able to click cancel to exit loop
d) Display values of the names array on a new line in the element created above
e) Loop through the names array
1. Retrieve each name starting at the end (last element in array)
2. Generate a random number between 0 and the length of phrasesArray and use this number as your index to retrieve a phrase from that array
3. Display each name followed by a random phrase in a new line names[i] + phrasesArray[randNum]
4. Do Not use the same phrase more than once
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
